My Blog List

Thursday, October 12, 2023

Getting all GPO Drive maps in a Domain with PowerShell

 $Reports = Get-GPO -All | Get-GPOReport -ReportType Xml

$DriveMappings = @()

ForEach ($Report In $Reports) {

  $GPO = ([xml]$Report).GPO

  $LinkCount = ([string[]]([xml]$Report).GPO.LinksTo).Count

  $Enabled = $GPO.User.Enabled

  ForEach ($ExtensionData In $GPO.User.ExtensionData) {

    If ($ExtensionData.Name -eq "Drive Maps") {

      $Mappings = $ExtensionData.Extension.DriveMapSettings.Drive

      ForEach ($Mapping In $Mappings) {

        $DriveMapping = New-Object PSObject -Property @{

          GPO         = $GPO.Name

          LinkCount   = $LinkCount

          Enabled     = $Enabled

          DriveLetter = $Mapping.Properties.Letter + ":"

          Label       = $Mapping.Properties.label

          Path        = $Mapping.Properties.Path

        }

        $DriveMappings += $DriveMapping

      }

    }

  }

}

Write-Output $DriveMappings | ft GPO, LinkCount, Enabled, DriveLetter, Label, Path -AutoSize


ref: https://www.easy365manager.com/how-to-find-gpo-drive-mapping/

No comments:

Post a Comment

Steps to extract ntfs share details from file server shares

As part of a file server consolidation effort, I was tasked to come up with a method to move multiple shares on multiple shares to a WSFC. I...