Here’s an easy way to add Windows users in Powershell.
net user username 'password' /add |
Passwords must meet requirements. While you are at it, give it Admin rights.
net localgroup Administrators username /add |
cloud engineer
Here’s an easy way to add Windows users in Powershell.
net user username 'password' /add |
net user username 'password' /add
Passwords must meet requirements. While you are at it, give it Admin rights.
net localgroup Administrators username /add |
net localgroup Administrators username /add
Here’s the command to test a network connection in Powershell.
C:> Test-NetConnection -ComputerName server -Port 443 |
C:> Test-NetConnection -ComputerName server -Port 443
Result:
ComputerName : server RemoteAddress : 10.0.0.5 RemotePort : 443 InterfaceAlias : Ethernet 0 SourceAddress : 10.1.1.34 TcpTestSucceeded : True |
ComputerName : server RemoteAddress : 10.0.0.5 RemotePort : 443 InterfaceAlias : Ethernet 0 SourceAddress : 10.1.1.34 TcpTestSucceeded : True
This is a Powershell script to restart a service if it’s down.
$ServiceName = 'GCEAgent' $arrService = Get-Service -Name $ServiceName if ($arrService.Status -ne 'Running') { Start-Service $ServiceName write-host $arrService.status write-host 'Service starting' Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq 'Running') { Write-Host 'GCE Agent Service is now Running' } } else { Write-Host 'GCE Agent Service is Running' } |
$ServiceName = 'GCEAgent' $arrService = Get-Service -Name $ServiceName if ($arrService.Status -ne 'Running') { Start-Service $ServiceName write-host $arrService.status write-host 'Service starting' Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq 'Running') { Write-Host 'GCE Agent Service is now Running' } } else { Write-Host 'GCE Agent Service is Running' }