You've already forked SharedScripts
mirror of
https://github.com/jaapbrasser/SharedScripts.git
synced 2025-12-24 21:51:38 +02:00
Updated two scripts
This commit is contained in:
@@ -111,7 +111,7 @@ Will retrieve the installed programs on server01/02 that are passed on to the fu
|
||||
}
|
||||
} | ForEach-Object -Begin {
|
||||
if ($SimilarWord) {
|
||||
$Regex = [regex]"(^(.+?\s){$SimilarWord}).*$|(.*)"
|
||||
$Regex = [regex]('(^(.+?\s){{0}}).*$|(.*)' -f $SimilarWord)
|
||||
} else {
|
||||
$Regex = [regex]"(^(.+?\s){3}).*$|(.*)"
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ Will remove the User01 account to the Administrators group on all servers and co
|
||||
$Computer | ForEach-Object {
|
||||
Write-Verbose "Removing '$ADResolved' from Administrators group on '$_'"
|
||||
try {
|
||||
([adsi]"WinNT://$_/Administrators,group").remove($Trustee)
|
||||
([adsi]"WinNT://$_/Administrators,group").psbase.remove($Trustee)
|
||||
Write-Verbose "Successfully completed command for '$ADResolved' on '$_'"
|
||||
} catch {
|
||||
Write-Warning $_
|
||||
@@ -120,7 +120,7 @@ Will remove the User01 account to the Administrators group on all servers and co
|
||||
Get-Content -Path $InputFile | ForEach-Object {
|
||||
Write-Verbose "Removing '$ADResolved' from Administrators group on '$_'"
|
||||
try {
|
||||
([adsi]"WinNT://$_/Administrators,group").remove($Trustee)
|
||||
([adsi]"WinNT://$_/Administrators,group").psbase.remove($Trustee)
|
||||
Write-Verbose 'Successfully completed command'
|
||||
} catch {
|
||||
Write-Warning $_
|
||||
|
||||
Reference in New Issue
Block a user