[gptalk] Re: Get-SDMgpo only returning 3/4
- From: "Cruz, Jerome L" <jerome.l.cruz@xxxxxxxxxx>
- To: "gptalk@xxxxxxxxxxxxx" <gptalk@xxxxxxxxxxxxx>
- Date: Wed, 25 Jun 2008 11:41:13 -0500
Hi Kevin,
Several possibilities (off the top of my head...not even looking at the code
yet):
1) The account used to run the script does not have access to all of the
GPOs.
2) Something wrong with "spaces" in the display names of the GPOs (causing
them to be the same name...data overwriting)
3) [low probability] Many GPOs have the same name (e.g. New Group Policy
Object).
Jerry Cruz | Group Policies Product Manager | Boeing IT
From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Kevin Gay
Sent: Wednesday, June 25, 2008 8:46 AM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Get-SDMgpo only returning 3/4
I'm using Powershell to create backups of all our GPO's, basically a daily
script that runs and drops them into a folder with the GPO's name as the folder
name. I've attached links and the script at the bottom if anyone would like to
use it. But the real problem is that Get-SDMgpo only retrieves about 3/4 of all
the GPOs in the domain, we have 61 GPO's, running Get-SDMgpo * (which grabs
them all) only returns 48. So I'm wondering if anyone else has had this problem
and if they resolved it. I'm also using the free download of the cmdlets.
http://www.gpoguy.com/powershell.htm - explanation of the cmdlets and download
location. You'll need to see the howto so you can add the cmdlets to powershell.
http://gnuwin32.sourceforge.net/packages/grep.htm - for grep used in the
script, I just placed the files in system32.
Script:
#Add-PSSnapin SDMSoftware.PowerShell.GPMC #uncomment in case you get an error
saying Get-SDMgpo is not understood.
$gpmList = Get-SDMgpo * | grep "DisplayName"
$strSavePath = \\server\share"
# the log doesn't seem to work as well as I expected it to.
$Date = Get-Date -format MM-dd-yyyy
$Logs = \\server\share\Logs\" + $Date + ".txt"
foreach ($gpmGPOName in $gpmList)
{
# Essentially this is performing an InStr() and then a Right()
# so it can grab only the GPO name.
$Index = $gpmGPOName.indexof(":") + 2
$Length = $gpmGPOName.length - $Index
# See if it outputs correctly
# echo $gpmGPOName.substring($Index, $Length)
$gpmName = $gpmGPOName.substring($Index, $Length)
echo $gpmName
# put together the full path
$strLocation = $strSavePath + "\" + $gpmName
# Check for folder to put GPO in
if (!(Test-Path $strLocation))
{
md $strLocation
}
# Log some info.
echo $gpmName >> $Logs
echo $gpmName
Export-SDMgpo -Name $gpmName -location $strLocation
-Description $gpmName >> $Logs
}
Thanks,
Kevin Gay
Desktop Administrator
Cherokee Nation Enterprises
918-384-6998
Catoosa, OK 74015
- Follow-Ups:
- [gptalk] Re: Get-SDMgpo only returning 3/4
- From: Kevin Gay
- References:
- [gptalk] Get-SDMgpo only returning 3/4
- From: Kevin Gay
Other related posts:
- » [gptalk] Get-SDMgpo only returning 3/4
- » [gptalk] Re: Get-SDMgpo only returning 3/4
- » [gptalk] Re: Get-SDMgpo only returning 3/4
- » [gptalk] Re: Get-SDMgpo only returning 3/4
- » [gptalk] Re: Get-SDMgpo only returning 3/4
- » [gptalk] Re: Get-SDMgpo only returning 3/4
- » [gptalk] Re: Get-SDMgpo only returning 3/4
- » [gptalk] Re: Get-SDMgpo only returning 3/4
- [gptalk] Re: Get-SDMgpo only returning 3/4
- From: Kevin Gay
- [gptalk] Get-SDMgpo only returning 3/4
- From: Kevin Gay