########################################################
#
# out-zip
#
# Usage:
#
# To zip up some files:
# ls c:\source\*.txt | out-zip c:\target\archive.zip $_
#
# To zip up a folder:
# gi c:\source | out-zip c:\target\archive.zip $_
########################################################
function out-zip ($path)
{ $files = $input
if (-not $path.EndsWith('.zip')) {$path += '.zip'}
if (-not (test-path $path)) { set-content $path ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) }
$ZipFile = (new-object -com shell.application).NameSpace($path)
$files | foreach {$zipfile.CopyHere($_.fullname)} }
#Получаем текущую папку из пути к скрипту
$scriptDir = Split-Path -parent $MyInvocation.MyCommand.Definition
#Получаем все не подписанные МП
$UnsealedMP = Get-ManagementPack | where {$_.Sealed -eq $False}foreach($mp in $UnsealedMP)
{ #Производим экспорт
export-managementpack -managementpack $mp -path $scriptDir
}
#Запаковываем все МП
dir $scriptDir"\*.xml" | out-zip $scriptDir"\UnsealedMPs.zip" $_
#Удаляем МП
dir $scriptDir"\*.xml" | del