Here’s a little powershell script that I use for exporting all unsealed MPs. It’s really useful to run once in a while so you have a backup of all unsealed MPs.
The script will create a new folder with the current date and store all MPs in that folder. Change the $OutPutDir variable to a folder of your choice.
Add-PSSnapin SMCMDLetSnapIn $OutPutDir = "C:\Unsealed MPs\" $UnsealedMPs = Get-SCSMManagementPack | ?{ ! $_.Sealed } $CurrentDate = Get-Date $CurrentDate = $CurrentDate.ToShortDateString() $CompletePath = ($OutPutDir + $CurrentDate) if ( ! (test-path $CompletePath)) { $output = New-Item -Type Directory -Name $CurrentDate -Path $OutPutDir } $UnsealedMPs | %{ " Exporting: {0}" -f $_.Name $_ | Export-SCSMManagementPack -directory "$CompletePath" }
When I run the script at PowerShell window, I get the following errors for each MP:
Exporting: ServiceManager.Dashboards
Export-SCManagementPack : A parameter cannot be found that matches parameter name ‘directory’.
At line:3 char:46
+ $_ | Export-SCSMManagementPack -directory <<<< "$CompletePath"
+ CategoryInfo : InvalidArgument: (:) [Export-SCManagementPack], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,SMLets.ExportManagementPackCommand
Hi Ozge,
If I remember correctly, the switch has changed and is now -path instead of -directory.
Rgds
//Anders
Hi, help me, please
my script:
Import-Module smlets
$OutPutDir = “C:\Export Management Pack”
$CurrentDate = Get-Date
$CurrentDate = $CurrentDate.ToShortDateString()
$CompletePath = ($OutPutDir + $CurrentDate)
if ( ! (test-path $CompletePath)){$output = New-Item -Type Directory -Name $CurrentDate -Path $OutPutDir}
Get-SCSMManagementPack | where{$_.sealed -eq $False} | Export-SCSMManagementPack -Path $output
same error on-path (((
This probably wont help the users above me… but the correct command is -TargetDirectory
The way I found this out (to aid you in solving similar future errors) was by typing get-help on the export-scsmmanagementpack and reviewing available options.
If anyone is interested I am opening a website soon and its going to contain alot of SCSM tips, email me at srlearnalot@gmail.com
Cheers 🙂
Edited slightly so this can be used to backup multiple SCSM deployments to a single file share.
$MG = Get-ScManagementGroupConnection
$MG.ManagementGroupName
Â
$OutPutDir = “\\\\” + $MG.ManagementGroupName
Â
$UnsealedMPs = Get-SCSMManagementPack | ?{ ! $_.Sealed }
Â
$CurrentDate = Get-Date
$CurrentDate = $CurrentDate.ToShortDateString()
$CompletePath = ($OutPutDir + “\” + $CurrentDate)
Â
if ( ! (test-path $CompletePath))
{
   $output = New-Item -Type Directory -Name $CurrentDate -Path $OutPutDir
}
Â
$UnsealedMPs | %{
   ”  Exporting: {0}” -f $_.Name
   $_ | Export-SCSMManagementPack -path “$CompletePath”
   }