Skip to content

Commit

Permalink
Fixed issue where missing site PS drive when importing :shipit:
Browse files Browse the repository at this point in the history
  • Loading branch information
codaamok committed Oct 16, 2020
1 parent 4629605 commit 279f660
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Fixed
- Create PS drive for site code and server if it does not exist upon importing the module

## [1.7.20200925.0] - 2020-09-25
### Fixed
Expand Down
8 changes: 8 additions & 0 deletions PSCMContentMgmt/ScriptsToProcess/Set-Variables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ try {
Write-Warning ('Could not auto-populate variable $CMSiteCode, either set this yourself or pass -SiteCode to all functions (Reason: "{0}" while querying SMS_ProviderLocation on "{1}")' -f $_.Exception.Message, $CMSiteServer)
$CMSiteCode = $null
}
try {
if ($null -eq (Get-PSDrive -Name $CMSiteCode -PSProvider "CMSite" -ErrorAction "SilentlyContinue")) {
$null = New-PSDrive -Name $CMSiteCode -PSProvider "CMSite" -Root $CMSiteServer -ErrorAction "Stop"
}
}
catch {
Write-Error ('Could not create new PS drive "{0}" (Reason: "{1}")' -f $CMSiteCode, $_.Exception.Message) -Category $_.CategoryInfo.Category
}
}
catch {
Write-Warning ('Could not auto-populate variable $CMSiteServer, either set this yourself or pass -SiteServer to all functions (Reason: "{0}" while trying to read "Server" value from key "{1}")' -f $_.Exception.Message, $RegKey)
Expand Down

0 comments on commit 279f660

Please sign in to comment.