• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

powershell

Adding New Users in Powershell

December 23, 2020

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

Filed Under: Windows Tagged With: admin, new, powershell, rights, users

Powershell Test Network Connection

June 15, 2020

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

Filed Under: Windows Tagged With: port, powershell, test-netconnection, windows

GCE Agent Powershell

May 11, 2020

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' }

Filed Under: Cloud, Windows Tagged With: check, powershell, restart, service

Tail A File in Windows Server

November 19, 2019

Linux has tail command. What about Windows? You can use Powershell to tail a file.

Get-Content myLog.log –Wait

Get-Content myLog.log –Wait

Filed Under: Windows Tagged With: file, log, powershell, tail, windows

  • Home
  • About
  • Archives

Copyright © 2023