Skip to content
This repository has been archived by the owner on Nov 13, 2018. It is now read-only.
andrebocchini edited this page Nov 23, 2012 · 8 revisions

Here are a few other examples of things you can do. Be sure to also take a look at the example script.

Get a list of all computers found on the site

Get-SCCMComputer 

Get a list of computers that contain the word "SALES" in their names

Get-SCCMComputer "*SALES*"

Create a new computer

New-SCCMComputer -computerName "NEW-COMPUTER" -macAddress "00:00:00:00:00:00"

Get a list of all collections found on the site

Get-SCCMCollection

Rename a collection

$collection = Get-SCCMCollection -collectionId "XXX000E9"
$collection.Name = "New Name"
Save-SCCMCollection $collection

Rename a package

$package = Get-SCCMPackage -packageId "XXX001D2"
$package.Name = "New Name"
Save-SCCMPackage $package

Get a list of all advertisements found on the site

Get-SCCMAdvertisement

Get a list of all the package and advertisement folders found on the site

Get-SCCMFolder

Move a package into an existing folder called "Test Packages"

$folder = GetSCCMFolder "Test Packages"
Move-SCCMPackageToFolder -packageId "XXX23034" -targetFolderNodeId $folder.ContainerNodeID

Set a computer variable

$variable = New-SCCMComputerVariable -variableName "Test Variable" -variableValue "Variable Value" -isMasked $false
Set-SCCMComputerVariables -resourceId 1234 -variableList $variable

Get a list of a collection's variables

Get-SCCMCollectionVariables -collectionId "XXX00032"

Find out the status of an advertisement assigned to a collection

$computers = Get-SCCMCollectionMembers -collectionId "XXX000EA"
foreach($computer in $computers) {
    Get-SCCMAdvertisementStatusForComputer -advertisementId "XXX20160" -resourceId $computer.ResourceID
}

You can then make a decision based on, for example, advertisement failures and send an alert email to the person responsible for fixing the issue.

Get details of a collection's maintenance windows

Get-SCCMMaintenanceWindows -collectionId "XXX00012"

Create a new collection

New-SCCMStaticCollection -collectionName "New Collection" -parentCollectionId "XXX12000"

Add a computer to a collection

Add-SCCMComputerToCollection -resourceId 3245 -collectionId "XXX12000"
Clone this wiki locally