Download: http://eddiejackson.net/apps/ConfigMgr2012PowerShellCmdlets.msi
Also see: SCCM – Automated WSUS & SUP Install
Clear-Host $SMSProvider = "SCCM.DOMAIN.COM" Function Get-SiteCode { $SMSQuery = “SELECT * FROM SMS_ProviderLocation” $SMSObject = Get-WmiObject -Query $SMSQuery -Namespace “root\sms” -ComputerName $SMSProvider $SMSObject | ForEach-Object { if($_.ProviderForLocalSite) { $SiteCode = $_.SiteCode } } return $SiteCode | Out-Null } Get-SiteCode Write-Host "Provider:" $SMSProvider Write-Host "" Write-Host "Site Code Detected:" $SiteCode Write-Host "" $SUPRole = [wmiclass]("\\$SMSProvider\root\SMS\Site_$($SiteCode):SMS_SoftwareUpdate") $SUPParams = $SUPRole.GetMethodParameters("SyncNow") $SUPParams.fullSync = $true $ReturnCode = $SUPRole.SyncNow($SUPParams) Write-Host "Sync Return Code:" $ReturnCode.ReturnValue Write-Host "" if ($Return.ReturnValue -eq "0") { Write-Host "Sync was successful!" } else { Write-Host "Sync failed!" } # show sms info Get-WmiObject -Query $SMSQuery -Namespace “root\sms” -ComputerName $SMSProvider
Output
__GENUS : 2
__CLASS : SMS_ProviderLocation
__SUPERCLASS :
__DYNASTY : SMS_ProviderLocation
__RELPATH : SMS_ProviderLocation.Machine=”SCCM.DOMAIN.com”,SiteCode=”001″
__PROPERTY_COUNT : 4
__DERIVATION : {}
__SERVER : SCCM
__NAMESPACE : ROOT\sms
__PATH : \\SCCM\ROOT\sms:SMS_ProviderLocation.Machine=”SCCM.DOMAIN.com”,S
iteCode=”001″
Machine : SCCM.DOMAIN.com
NamespacePath : \\SCCM.DOMAIN.com\root\sms\site_001
ProviderForLocalSite : True
SiteCode : 001
PSComputerName : SCCM
Detected Site Code: 001
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
PSComputerName :
Sync was successful!