SCCM Module for PowerShell

In a post a few days ago I mentioned “some slightly modified functions from Michael Niehaus“.

Well… Why not share them.

Save this as a module, load it and play around.

2010-03-26 – Moved to https://snowland.se/sccm-posh/

Some examples on what you can do:

# List all available SCCM commands
Get-SCCMCommands

# Create an SCCM-Connection to the local server
$sccm = Connect-SCCMServer -Verbose

# Create a new collection with a collection rule
$newCollection = New-SCCMCollection -SccmServer $sccm -name "Some Collection Name" -Verbose
Add-SCCMCollectionRule -Server $sccm -collectionID $newRoot.CollectionId -queryExpression "SELECT * FROM SMS_R_System" -queryRuleName "All Systems" -Verbose

# Count files in the inboxes
$sccm | Get-SCCMInboxes

# Get a package
$MyPackage = Get-SCCMPackage -server $sccm -filter "Name = 'Some Package Name'"

If you have some comments, ideas and things to add… Comment this post or shoot me an .


Scandinavian chars in cmd-files

Got a scriptingquestion from a colleague, wasn’t that easy to find on google.

But with Windows Search I did find an old cmd-script that had exactly that problem sorted out.

So, the question was about scandinavian chars in a cmd-script. Some paths are named with non English letters and when you use them in a script it translates to a strange char instead of the letter.

This works fine:

DEL /F /Q "%USERPROFILE%\Local Settings\Some Directory\*.*"

This doesn’t work since there is a scandinavian letter in the path:

DEL /F /Q "%USERPROFILE%\Lokala inställningar\Some Directory\*.*"

To fix it you need to change codepage, like this:

CHCP 850
DEL /F /Q "%USERPROFILE%\Lokala inställningar\Some Directory\*.*"

You might need to use different codepage depending on the language you are using.

Some more info on MSDN