PoshCode Archive  Artifact [9f7677b816]

Artifact 9f7677b81625dd6f9b5a42e0d72d58bbf688155f03b4ebe417c24552debc0577:

  • File Get-GPOUNCPaths.ps1 — part of check-in [1d14720044] at 2018-06-10 14:06:43 on branch trunk — This script retrieves the UNC paths from all group policies in the domain. Useful during file server cutovers and renaings. (user: Justin Grote size: 1167)

# encoding: ascii
# api: powershell
# title: Get-GPOUNCPaths
# description: This script retrieves the UNC paths from all group policies in the domain. Useful during file server cutovers and renaings.
# version: 0.1
# type: script
# author: Justin Grote
# license: CC0
# x-poshcode-id: 6039
# x-archived: 2016-05-17T07:00:07
# x-published: 2016-10-05T22:23:00
#
#
#Get-GPOUNCPaths.ps1
#This script retrieves the UNC paths from all group policies in the domain

$gpos = get-gpo -all
foreach ($gpo in $gpos) {

    [string]$xmlReport = $gpo | Get-GPOReport -reporttype xml

    $searchResults = $xmlReport -split '["\n\r"|"\r\n"|\n|\r]' | where {$_} | Select-String -pattern '\\\\.*\\.*' -context 3

    foreach ($searchResult in $searchResults) {
        
        $returnParams = [ordered]@{}
        $returnParams.GUID = $gpo.id
        $returnParams.Name = $gpo.DisplayName
        $returnParams.Line = $searchResult.LineNumber
        $returnParams.Match = $searchResult.Line
        $returnParams.Context = $searchResult.ToString()

        # Output a search result 
        new-object PSObject -Property $returnParams

    }
}