Powershell: Difference between revisions

From roonics
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
=Powershell=
=Powershell=
==Useful Commands==
==Useful Commands==
===Show command history===
<pre>get-history | more</pre>
===Test if port open from one server to another===
===Test if port open from one server to another===
<pre>Test-NetConnection 10.10.10.10 -port 445</pre>
<pre>Test-NetConnection 10.10.10.10 -port 445</pre>

Revision as of 11:16, 29 August 2019

Powershell

Useful Commands

Show command history

get-history | more

Test if port open from one server to another

Test-NetConnection 10.10.10.10 -port 445

Example output:

ComputerName           : 10.10.10.10
RemoteAddress          : 10.10.10.10
RemotePort             : 445
InterfaceAlias         : Ethernet
SourceAddress          : 10.10.10.20
PingSucceeded          : True
PingReplyDetails (RTT) : 29 ms
TcpTestSucceeded       : True

Check who rebooted the server

Get-EventLog –Log System –Newest 100 | Where-Object {$_.EventID –eq ‘1074’} | FT MachineName, UserName, TimeGenerated -AutoSize

Example output:

MachineName          UserName           TimeGenerated
-----------          --------           -------------
server01.lab.local LABLOCAL\user01 28/8/2018 4:28:20 PM