Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

using Powershell, How to list all servers with region format other than English (Australia) ?

Hi,

Can anyone here please assist me how to modify the script below to display the servers Locale and Regional settings in the domain ?

$path = "C:\temp\"
$serverlist = Get-QADComputer -SearchRoot 'mydomain.local/Servers/Production Servers' -OSName "Windows*Server*" -ShowProgress -Activity
 
foreach ($server in $serverlist){
    $result = Test-Connection $server -Count 1 -Quiet
    if ($result -eq "True") {
         # I need some help here.....
    }
    else {
        Add-Content "$path\OfflineServers.txt" -Value $server
    }
}

Open in new window


because for some servers, I received confusing timestamp MM/DD/YYYY instead of DD/MM/YYYY as the standard in our country.

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of marek1712
marek1712
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Albert Widjaja

ASKER

Marek,

will that works for Win2003 host ?
If it has PowerShell 2.0 installed - yes. Make sure to enable WinRM though (i.e. through winrm quickconfig).
Alternatively - you can check this WMI class, especially Locale and OSLanguage properties.
Hi marek,

for some server, I got  the following error with WinRM:

[DomainController01-VM] Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in
 the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the
WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following c
ommand on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Trou
bleshooting Help topic.
    + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionStateBroken

how to perform Try catch to change the error message into just the server name only that needs to be enabled rahter than the full detailed error message ?

this is your script that I have modified:

$computers = Get-QADComputer -SearchRoot "domain.com/Servers/DC Servers" | Where-Object {(Test-Connection $_.Name -Count 1 -Quiet)}
$cred = Get-Credential -Credential "DOMAIN\Administrator"
ForEach ($item in $computers) {
	try {
		Invoke-Command -ScriptBlock {$Host.CurrentCulture} -ComputerName $item.Name -Credential $cred
	} catch [Exception] {    
	    If ($_.Exception -is [System.Management.Automation.Remoting.PSRemotingTransportException]) {
	        Write-Host "Error while sending command to the " $item.Name " server"
	    } Else {
	        $_.Exception.GetType().FullName
	    } 
	}
}

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Marek,

Yes with the winrm quickconfig command it enables the Powershell.

About hundreds of the server is not running so it is going to take very long time to enable it manually one by one.

But as for splitting the error, I'm not sure how to so that since I'm just a beginner in Powershell. I appreciate any help and suggestion so that I can export it to csv for easy read.

Thanks