misc of command
Windows get uptime
net stats srv|findstr
systeminfo | find "System Boot Time:"
eventvwr.msc -> filter EventID(6005)
Control a service
net start tlntsvr
sc \\hostname start tlntsvr
Enable telnet service
1
2
3
4
5
6
7$tlntsvr = gwmi -ComputerName webserver -Class Win32_Service -filter "name='tlntsvr'" -Credential $cred
$tlntsvr.ChangeStartMode("Manual") (default it is Disabled)
$tlntsvr.StartService()
$ihs = gwmi -ComputerName webserver -Class Win32_Service -filter "name like 'IBM%1.3%'" -Credential $credEnable remote desktop
1
2
3
4
5
6
7$terminalService = gwmi -Class Win32_TerminalServiceSetting -Namespace root\cimv2\terminalservices -ComputerName webserver -Credential $cred //Windows Vista and Windows Server 2008
$terminalService = gwmi -Class Win32_TerminalServiceSetting -Namespace root\cimv2 -ComputerName webserver -Credential $cred //Windows XP and Windows Server 2003
$terminalService.AllowTsConnections // test the state
$terminalService.SetAllowTSConnections(1)View eventlog by powershell
1
2
3
4
5
6
7
8
9$username = "admin"
$password = "password"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
$time = [System.Management.ManagementDateTImeConverter]::ToDmtfDateTime((Get-Date).AddHours(-72))
gwmi Win32_NTLogEvent -filter "(LogFile='System') AND (Type='Error') AND (TimeWritten >= '$time')" -computer webserver -credential $cred | ft EventCode, EventType, Message -autoOpen remote server path
net use \\webserver\ipc$ password /user:username \\werbserver\c$
Reference
http://ss64.com/nt/sc.html
http://www.petri.co.il/check-uptime-in-server-2008.htm"