Skip to content

Commit 279f660

Browse files
committed
Fixed issue where missing site PS drive when importing :shipit:
1 parent 4629605 commit 279f660

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

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

810
## [1.7.20200925.0] - 2020-09-25
911
### Fixed

PSCMContentMgmt/ScriptsToProcess/Set-Variables.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ try {
88
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)
99
$CMSiteCode = $null
1010
}
11+
try {
12+
if ($null -eq (Get-PSDrive -Name $CMSiteCode -PSProvider "CMSite" -ErrorAction "SilentlyContinue")) {
13+
$null = New-PSDrive -Name $CMSiteCode -PSProvider "CMSite" -Root $CMSiteServer -ErrorAction "Stop"
14+
}
15+
}
16+
catch {
17+
Write-Error ('Could not create new PS drive "{0}" (Reason: "{1}")' -f $CMSiteCode, $_.Exception.Message) -Category $_.CategoryInfo.Category
18+
}
1119
}
1220
catch {
1321
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)

0 commit comments

Comments
 (0)