1
0
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:
Jaap Brasser
2016-09-29 18:20:08 +02:00
parent 0d4e237ce3
commit aa7f807b6d
2 changed files with 3 additions and 3 deletions

View File

@@ -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}).*$|(.*)"
}

View File

@@ -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 $_