Bäcke's – backes.nu

Bäcke – Stockholm – Sweden

Uppdatera Configmgr Content, där det behövs

Återigen, Rikard Rönnkvist spar mig massor av tid med sina PowerShell-script, tack!

    $sccmServer = "configmgr.snowland.se",
    $sccmSiteCode = "ABC",
    $failStates = "2, 3, 5, 6", # Retrying and Failed (Both Install and Removal)
    $packageTypes = "0, 3, 4, 8, 257, 258" # Not checking 5 (SUP) due to automatic deployments
Write-Host "Searching for failed content distributions"
ForEach ($FailedDist in (Get-WmiObject -ComputerName $sccmServer -Namespace "ROOT\SMS\Site_$($sccmSiteCode)" -Query "SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE State IN ($($failStates)) AND PackageType IN ($($packageTypes))" | Sort-Object PackageID)) {
    # Figure out servername from NalPath
    $failedServer = $FailedDist.ServerNALPath.Substring($FailedDist.ServerNALPath.LastIndexOf("]")+3).Trim("\")
    # Get the distribution points that content wouldn't distribute to
    ForEach ($FailedDPDist in (Get-WmiObject -ComputerName $sccmServer -Namespace "ROOT\SMS\Site_$($sccmSiteCode)" -Query "SELECT * FROM SMS_DistributionPoint WHERE SiteCode='$($FailedDist.SiteCode)' AND PackageID='$($FailedDist.PackageID)' AND ServerNALPath LIKE '%$($failedServer)%'") ) {
        # Refresh content on the selected DP
        Write-Host "Refreshing $($FailedDPDist.PackageID), type $($FailedDist.PackageType) in state $($FailedDist.State) on $($failedServer)"
        $FailedDPDist.RefreshNow = $true
        $FailedDPDist.Put() | Out-Null
Write-Host "Done!"

Tack till Rikard Rönnkvist, källa: SnowLand

Exportera / Importera Boot-image drivrutiner till ny Boot-image

Återigen, ett mycket bra PowerShell-script som besparar massa tid.

Function Export-BootImageDrivers {
    PARAM (
        [String] $ImageId,
        [String] $ExportXml
    $drivers = @{}
    (Get-CMBootImage -Id $ImageId).ReferencedDrivers | ForEach-Object {
        Write-Verbose "Found driver ID - $($_.Id)"
        $drivers.Add($_.Id, $_.SourcePath)
    $drivers | Export-Clixml -Path $ExportXml
Function Import-BootImageDrivers {
    PARAM (
        [String] $ImageId,
        [String] $ExportXml
    $BootImage = Get-CMBootImage -Id $ImageId
    $drivers = Import-Clixml -Path $ExportXml
    $drivers.GetEnumerator() | ForEach-Object {
        Write-Verbose "Adding driver ID - $($_.Name)"
        Set-CMDriver -Id $_.Name -AddBootImagePackage $BootImage -UpdateDistributionPointsforBootImagePackage $false -Force

Exportera först drivrutinerna

Export-BootImageDrivers -ImageId “ABC00123” -ExportXml “D:\Script\PS\drivers.xml”

Uppgradera Boot-imagen

Sedan importera drivrutinerna

Import-BootImageDrivers -ImageId “ABC00345” -ExportXml “D:\Script\PS\drivers.xml”

Tack till Rikard Rönnkvist, källa: SnowLand

By continuing to use this site, you agree to the use of cookies. more information

Your settings for this site is set to "allow cookies" to give you the best experience. If you continue to use the site without changing your settings for cookies, or if you click "Accept" below, you agree to this.