Tip: You can list the GC (Global Catalog) servers with Powershell.
1 2 3 4 5 6 7 8 |
# Solution 1 Get-ADDomainController -Filter {IsGlobalCatalog -eq $true} # Solution 2 ([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).FindAllGlobalCatalogs() | Select-Object -Property Name [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs | Select-Object -Property Name |
Note: Get-ADDomainController is a cmdlet from the activediretory module.
Pingback: Powershell Tip #21: Import specific cmdlets from a module | Powershell Guru
Pingback: Powershell Tip #23: Get Tombstone Lifetime | Powershell Guru
Hi,
I have a file myfile.txt and it has only one line. line is as given below.
I wanted to replace if=”${copy}” to blank (wanted to delete if=”${copy}”) i.e. file line should be as given below
I have tried with command
powershell -Command “(gc myfile.txt) -replace ‘if=”${copy}”‘, ” | Out-File myfile.txt”
but it does not replace with BLANK .
Thanks,
Hi,
Use the Replace method instead.
Replace operator
(gc file.txt) -replace 'if="${copy}"', ""
Replace method
(gc file.txt).Replace('if="${copy}"', "")