powershell bashrc equivalent

One complaint I hear a lot from the linux users who have to do windows admin work for a random project the most common thing I hear a complaint about is a bashrc equivalent. I’ve been asked about it a few times and knew you could do this at the local user level and replied with that but never thought about changing it at a system level.

 

If you’re mostly doing linux work you probably aren’t familiar with the scripting guy blog on microsoft.com. ¬†It has amazing content for doing windows automation work. Including a detailed description of how powershell profiles work ūüôā

Understanding the Six PowerShell Profiles

Simple service status checks and changes with powershell

We have a lot of third party applications with which we integrate. This tends to mean that there are a lot of windows services we want to make sure are running.  Typically this is left to operations departments, but sometimes (or to my experience, most times) you want to track this on your own.  Trust but verify.

 

Powershell is great for this. Simply use the Get-Service command with its -ComputerName param.

PS C:\users\scl>Get-Service -Name QuartzServer -ComputerName OMGITSASERVER

Status   Name               DisplayName
------   ----               -----------
Stopped  QuartzServer       Quartz Server

To change the status of the service you query for you can pipe the result to Set-Service.

PS C:\Users\scl2> gsv -Name QuartzServer -ComputerName OMGITSASERVER | set-service -status running



PS C:\Users\scl2> gsv -Name QuartzServer -ComputerName OMGITSASERVER

Status   Name               DisplayName
------   ----               -----------
Running  QuartzServer       Quartz Server

gsv is a default alias of Get-Service.