-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnect-SCCM.ps1
57 lines (44 loc) · 1.75 KB
/
Connect-SCCM.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function Connect-SCCM {
<#
.SYNOPSIS
connects to an SCCM Site
.DESCRIPTION
connects to an SCCM Site
.PARAMETER SiteServer
this parameter will be used to define the Site Server
this string parameter is mandatory
.PARAMETER SiteCode
this parameter will be used to define the Site Code
this string parameter is mandatory
.EXAMPLE
connect-SCCM SiteServer 'server.fqdn.net' -SiteCode 'P00'
.NOTES
File-Name: Invoke-SCCMScript.ps1
Author: Josh Burkard - [email protected]
Version: 0.1.00001
Changelog:
0.1.00001, 2019-07-29, Josh Burkard, initial creation
Links:
https://github.com/joshburkard/SCCM
#>
[CmdletBinding()]
Param (
[string]$SiteServer ,
[string]$SiteCode
)
# Import the ConfigurationManager.psd1 module
if ( $null -eq ( Get-Module ConfigurationManager ) ) {
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" -Scope Global
Write-Verbose "module 'ConfigurationManager' loaded"
}
# Connect to the site's drive if it is not already present
if ( ! ( Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue ) ) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $SiteServer -Scope Global | Out-Null
Write-Verbose "created PSDrive '$( $SiteCode )' on server '$( $SiteServer )'"
}
# Set the current location to be the site code.
if ( $( Get-Location ).Path -ne "$( $SiteCode ):\") {
Set-Location -Path "$( $SiteCode ):\"
Write-Verbose "connected to SCCM site '$( $SiteCode )'"
}
}