PowerShell for Windows Admins


October 14, 2016  12:09 PM

Current location

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Bash, Powershell
Windows 10 gives you the option of installing BASH on Ubuntu – https://msdn.microsoft.com/en-us/commandline/wsl/about also known as the Windows Subsystem for Linux (WSL). More information from https://blogs.msdn.microsoft.com/wsl/
I thought it would be interesting to compare some of the bash commands with their PowerShell equivalents.
First off – current location.
Its not obvious from the bash prompt where you are in the file system so you use pwd
root@RSsurfacePro2:~# pwd
/root
In PowerShell you use Get-Location
PS> Get-Location
Path
—-
C:\test
Interestingly you can use pwd in PowerShell
PS> pwd
Path
—-
C:\test
That’s because pwd is an alias for Get-Location
PS> get-alias pwd | fl
DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location
If you want to discover all existing aliases for Get-Location
PS> get-alias | where ResolvedCommand -like ‘get-location’ | fl
DisplayName       : gl -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location
DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location
You’ll find that many core PowerShell cmdlets have aliases corresponding to Linux commands. Note that they are removed for PowerShell on Linux to avoid confusion.
Look out for other comparisons soon.

October 13, 2016  7:06 AM

Easy and Expert

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Opinion

This is a very interesting article – https://powershell.org/2016/10/12/no-easy-button-for-configuration-management/.

The premise that there is no “easy” button in IT is spot on and fits with this quote from  Theodore Roosevelt:

“Nothing in the world is worth having or worth doing unless it means effort, pain, difficulty…”

IT is constantly changing – new technologies, new techniques, and new ways of looking at the problems.

The only way to survive is to keep learning. If you don’t you become part of the problem.

One of the comments castigating the author of the for declaring themselves a “newbie” given the work they’d put into learning DSC also caught my eye. When does someone move from being a newbie to becoming competent or even an expert?

Its as much in the mind of your audience as anything. I’ve been using PowerShell since the days of the version 1 beta code and have written and spoken more about the subject than I care to remember. Does that make me an expert? Many people seem to think so but as far as I’m concerned I’m still learning. So is everyone else that I consider an expert. To misquote

“Expertise is in the eye of the beholder”

When things change or you move onto something new the newbie clock gets reset so we’re all really newbies. Another way to think about it is that an expert is a newbie that has been working with the technology just that little bit longer.

Be wary of self proclaimed experts. The true experts tend to just get on with it.


October 4, 2016  12:50 PM

Filter early and WQL

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WMI

What’s wrong with this:

Get-CimInstance -ClassName Win32_Service |
where {$_.State -eq ‘Running’ -and $_.StartName -notlike ‘LocalSystem’ -and $_.StartName -notlike ‘NT Authority*’} |
select PSComputerName, Name, DisplayName, State, StartName

Nothing except that its inefficient. if you ran this against a remote machine the filtering would happen on the local machine AFTER you’d dragged everything across the network. May not matter for a few machines but when you get to hundreds or thousands of machines it will have an impact

You need to use a filter. First try would be something like this:

Get-CimInstance -ClassName Win32_Service  -Filter “State = ‘Running’ AND StartName != ‘LocalSystem’ AND NOT StartName LIKE ‘NT Authority%'”|
select PSComputerName, Name, DisplayName, State, StartName

Unfortunately any services with a NULL StartName will also be filtered out

This will work

Get-CimInstance -ClassName Win32_Service  -Filter “State = ‘Running’ AND Startname != ‘LocalSystem’ AND StartName != ‘NT AUTHORITY\\LocalService’ AND StartName != ‘NT AUTHORITY\\NetworkService'”|
select PSComputerName, Name, DisplayName, State, StartName

Same results are obtained with Get-WmiObject


October 3, 2016  2:52 AM

Opportunities come and go

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

The deadline for the submission of proposals for the 2017 has passed. We are NOT taking any new submissions. if you’ve been in communication regarding a submission thats fine its still under consideration and I’ll be in touch.

On the positive side the call for speakers for the European PowerShell conference has opened – http://www.powertheshell.com/psconfeu/


September 29, 2016  1:21 PM

PowerShell classes

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

I’ve just had an article on PowerShell classes published on the UK TechNet bog – https://blogs.technet.microsoft.com/uktechnet/2016/09/29/powershell-classes/


September 27, 2016  1:15 PM

Few days left for PowerShell & DevOps Global Summit 2007 session proposals

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

You have a few days left to get your sessions proposals submitted for PowerShell & DevOps Global Summit 2017 –  details from

https://powershell.org/2016/08/01/powershell-and-devops-global-summit-2017-call-for-topics/

For more topic ideas see

https://powershell.org/2016/09/06/nearing-last-call-for-powershell-summit-topic-proposals-topic-ideas/

We are treating end of September as a hard deadline so don’t delay


September 26, 2016  7:53 PM

Windows Server 2016 launches

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Windows Server 2016

The launch of Windows Server 2016 has been announced at Ignite – https://blogs.technet.microsoft.com/hybridcloud/2016/09/26/announcing-the-launch-of-windows-server-2016/

Evaluations can be downloaded from the link in the above post.

Soon be time to re-build the test lab


September 23, 2016  7:49 AM

September 2016–DSC Resource updates

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Two new modules of DSC resources are available:

OfficeOnlineServerDsc

SystemLocaleDsc

A number of updates to existing resources have been made available.

Details from https://blogs.msdn.microsoft.com/powershell/2016/09/21/dsc-resource-kit-september-release/


September 19, 2016  12:57 PM

Update-Help errors

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

One the latest build of Windows 10 – 14296 I’m getting errors when updating help. Three modules do’t seem to have help available

Update-Help : Failed to update Help for the module(s) ‘Microsoft.PowerShell.Operation.Validation’
with UI culture(s) {en-GB} : The value of the HelpInfoUri key in the module manifest must resolve to
a container or root URL on a website where the help files are stored. The HelpInfoUri
https://www.msn.com/en-gb/?ocid=NEFLS000′ does not resolve to a container.
At line:1 char:1
+ Update-Help -Force
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : InvalidHelpInfoUri,Microsoft.PowerShell.Commands.UpdateHelpCommand

Update-Help : Failed to update Help for the module(s) ‘PSScriptAnalyzer’ with UI culture(s) {en-US}
: The Help content at the specified location is not valid. Specify a location that contains valid
Help Content.
At line:1 char:1
+ Update-Help -Force
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : HelpContentXmlValidationFailure,Microsoft.PowerShell.Commands.UpdateHe
lpCommand

Update-Help : Failed to update Help for the module(s) ‘SecureBoot’ with UI culture(s) {en-GB} :
Unable to retrieve the HelpInfo XML file for UI culture en-GB. Make sure the HelpInfoUri property in
the module manifest is valid or check your network connection and then try the command again.
At line:1 char:1
+ Update-Help -Force
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCo
mmand

I’ve checked and the help isn’t available for en-US culture.


September 19, 2016  7:33 AM

Talk like a pirate day

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
General

In honor of International talk like a pirate day  – http://talklikeapirate.com/wordpress/

What’s a pirate’s favorite programming language?

R

What’s a pirate’s favorite load balancer?

ARR

= Application Request Routing –  see http://www.iis.net/learn/extensions/installing-application-request-routing-arr

Normal service may be resumed quite soon


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: