This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$servers = get-content C:\temp\potential_gateways.txt | |
foreach($server in $servers){ | |
Get-Service -ComputerName "$server" -Name "Bentley SELECT Server Gateway" -ErrorVariable serviceerr | |
if ($serviceerr.count -eq 0) { | |
Write-Host "$server appears to be a gateway server" | |
Out-File -InputObject $server -FilePath c:\temp\selectservers.txt -Append -Encoding ASCII | |
} | |
else{ | |
Write-Host "$server is not a gateway server" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create new GPO's named in the file, then import the right gpo into that policy | |
$gpos = get-content("c:\temp\gpos.txt") | |
foreach ($gpo in $gpos) { | |
import-gpo -backupgponame "$gpo" -targetname "restored - $gpo" -path "c:\temp\backups" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Backup GPO's who's names are in a file | |
import-module grouppolicy | |
$gpofile = "C:\temp\gpos.txt" | |
$gpos = get-content($gpofile) | |
foreach($gpo in $gpos) { | |
$gpobackup = backup-gpo $gpo -path "c:\temp\gpobackup" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##generate bootstrap.ini settings | |
$csv = Import-Csv -Path c:\temp\import.csv | |
del c:\temp\defaultgateway-out.txt | |
del c:\temp\defaultgateway-out1.txt | |
for ($i=0;$i -le $csv.count;$i++) { | |
##output assignments for [defaultgateway] string | |
$outstring = $csv[$i]."Default Gateway for Workstations (used to target deployroot)" + "=" + $csv[$i]."office name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$machines = get-content("c:\temp\machines.txt") | |
foreach ($machine in $machines) { | |
#check for DNS resolution | |
$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$machine'" | Select-Object StatusCode | |
if ($PingStatus.StatusCode -ne 0) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$filter = "<filter> " | |
$computername_string = "`"Computer`".`"Computer Name`" = " | |
$machines = Get-Content "c:\temp\del_machines.txt" | |
$filter_string = $filter | |
foreach ($machine in $machines) { | |
if ($machine -ne "ServerName") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
del "c:\temp\vpn_machines.txt" | |
$machines = gc "c:\temp\hosts" |% {$_.split("`t")[0]} | |
foreach ($machine in $machines) { | |
if ($machine.startswith('10.54')) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#needs to be adapted to eliminate the need for Quest AD add in and use the built-in AD stuff in | |
#POSH 2.0 | |
$machines = Get-Content "c:\temp\machines.txt" | |
foreach ($machine in $machines) { | |
Add-QADGroupMember "GroupName" -Member "contoso\$machine$" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$machines = Get-Content "c:\temp\machines.txt" | |
del c:\temp\not-in-ad.txt | |
foreach ($machine in $machines) { | |
#query AD to see if this machine exists. If not, write to a file | |
#uses the quest AD cmdlets..Probably need to change to built in AD cmdlets in POSH 2.0 | |
$this = Get-QADComputer -Identity "contoso\$machine$" -ErrorVariable $Error_get_computer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#read a list of CN's of groups from a file and remove the specified user from | |
#that group | |
#uses the quest AD cmdlets.. Probable need to change to built in AD stuff. | |
$groups = Get-Content "c:\temp\groups_to_remove.txt" | |
foreach ($group in $groups) | |
{ | |
Write-Host $group |
NewerOlder