|
1 | | -Function MP-Export |
2 | | -{ |
3 | | - $OutputPath = 'C:\Temp' |
4 | | - if ((Test-Path -Path "$OutputPath\Unsealed Management Packs") -eq $false) |
5 | | - { |
6 | | - Write-Host " Creating Folder: $OutputPath\Unsealed Management Packs" -ForegroundColor Gray |
7 | | - md "$OutputPath\Unsealed Management Packs" | Out-Null |
8 | | - } |
9 | | - else |
10 | | - { |
11 | | - Write-Host " Existing Folder Found: $OutputPath\Unsealed Management Packs" -ForegroundColor Gray |
12 | | - Remove-Item "$OutputPath\Unsealed Management Packs" -Recurse | Out-Null |
13 | | - Write-Host " Deleting folder contents" -ForegroundColor Gray |
14 | | - md "$OutputPath\Unsealed Management Packs" | out-null |
15 | | - Write-Host " Folder Created: $OutputPath\Unsealed Management Packs" -ForegroundColor Gray |
16 | | - } |
17 | | - |
18 | | - try |
19 | | - { |
20 | | - Get-SCOMManagementPack | Where{ $_.Sealed -eq $false } | Export-SCOMManagementPack -path "$OutputPath\Unsealed Management Packs" | out-null |
21 | | - Write-Host " Completed Exporting Management Packs" -ForegroundColor Green |
22 | | - } |
23 | | - catch |
24 | | - { |
25 | | - Add-Content -Path "$OutputPath\Unsealed Management Packs\Error.txt" -Value $Error |
26 | | - Write-Warning $_ |
27 | | - } |
28 | | - |
29 | | - if ((Test-Path -Path "$OutputPath\Sealed Management Packs") -eq $false) |
30 | | - { |
31 | | - Write-Host " Creating Folder: $OutputPath\Sealed Management Packs" -ForegroundColor Gray |
32 | | - md "$OutputPath\Sealed Management Packs" | Out-Null |
33 | | - } |
34 | | - else |
35 | | - { |
36 | | - Write-Host " Existing Folder Found: $OutputPath\Sealed Management Packs" -ForegroundColor Gray |
37 | | - Remove-Item "$OutputPath\Sealed Management Packs" -Recurse | Out-Null |
38 | | - Write-Host " Deleting folder contents" -ForegroundColor Gray |
39 | | - md "$OutputPath\Sealed Management Packs" | out-null |
40 | | - Write-Host " Folder Created: $OutputPath\Sealed Management Packs" -ForegroundColor Gray |
41 | | - } |
42 | | - |
43 | | - try |
44 | | - { |
45 | | - Get-SCOMManagementPack | Where{ $_.Sealed -eq $true } | Export-SCOMManagementPack -path "$OutputPath\Sealed Management Packs" | out-null |
46 | | - Write-Host " Completed Exporting Management Packs" -ForegroundColor Green |
47 | | - } |
48 | | - catch |
49 | | - { |
50 | | - Add-Content -Path "$OutputPath\Sealed Management Packs\Error.txt" -Value $Error |
51 | | - Write-Warning $_ |
52 | | - } |
| 1 | +$OutputPath = 'C:\Temp' |
| 2 | + |
| 3 | +if ((Test-Path -Path "$OutputPath\Unsealed Management Packs") -eq $false) |
| 4 | +{ |
| 5 | + Write-Host " Creating Folder: $OutputPath\Unsealed Management Packs" -ForegroundColor Gray |
| 6 | + md "$OutputPath\Unsealed Management Packs" | Out-Null |
| 7 | +} |
| 8 | +else |
| 9 | +{ |
| 10 | + Write-Host " Existing Folder Found: $OutputPath\Unsealed Management Packs" -ForegroundColor Gray |
| 11 | + Remove-Item "$OutputPath\Unsealed Management Packs" -Recurse | Out-Null |
| 12 | + Write-Host " Deleting folder contents" -ForegroundColor Gray |
| 13 | + md "$OutputPath\Unsealed Management Packs" | out-null |
| 14 | + Write-Host " Folder Created: $OutputPath\Unsealed Management Packs" -ForegroundColor Gray |
| 15 | +} |
| 16 | + |
| 17 | +try |
| 18 | +{ |
| 19 | + Get-SCOMManagementPack | Where{ $_.Sealed -eq $false } | Export-SCOMManagementPack -path "$OutputPath\Unsealed Management Packs" | out-null |
| 20 | + Write-Host " Completed Exporting Management Packs" -ForegroundColor Green |
| 21 | +} |
| 22 | +catch |
| 23 | +{ |
| 24 | + Add-Content -Path "$OutputPath\Unsealed Management Packs\Error.txt" -Value $Error |
| 25 | + Write-Warning $_ |
| 26 | +} |
| 27 | + |
| 28 | +if ((Test-Path -Path "$OutputPath\Sealed Management Packs") -eq $false) |
| 29 | +{ |
| 30 | + Write-Host " Creating Folder: $OutputPath\Sealed Management Packs" -ForegroundColor Gray |
| 31 | + md "$OutputPath\Sealed Management Packs" | Out-Null |
| 32 | +} |
| 33 | +else |
| 34 | +{ |
| 35 | + Write-Host " Existing Folder Found: $OutputPath\Sealed Management Packs" -ForegroundColor Gray |
| 36 | + Remove-Item "$OutputPath\Sealed Management Packs" -Recurse | Out-Null |
| 37 | + Write-Host " Deleting folder contents" -ForegroundColor Gray |
| 38 | + md "$OutputPath\Sealed Management Packs" | out-null |
| 39 | + Write-Host " Folder Created: $OutputPath\Sealed Management Packs" -ForegroundColor Gray |
| 40 | +} |
| 41 | + |
| 42 | +try |
| 43 | +{ |
| 44 | + Get-SCOMManagementPack | Where{ $_.Sealed -eq $true } | Export-SCOMManagementPack -path "$OutputPath\Sealed Management Packs" | out-null |
| 45 | + Write-Host " Completed Exporting Management Packs" -ForegroundColor Green |
| 46 | +} |
| 47 | +catch |
| 48 | +{ |
| 49 | + Add-Content -Path "$OutputPath\Sealed Management Packs\Error.txt" -Value $Error |
| 50 | + Write-Warning $_ |
53 | 51 | } |
0 commit comments