PowerShell FAQ: Top 5 Questions about PowerShell from the Field

Hi folks, my name is Thiago Cardoso and I deliver workshops and custom support for our customers related to PowerShell, and I wanted to talk to you today about the top 5 questions I receive in the field:

1. Is it possible to update Windows 7 with PowerShell version 5?

Yes, you can do this via WSUS, Windows Update, or direct download with Windows Management Framework 5.0 via aka.ms/psv5.

As a friendly reminder, PowerShell 5.0 is backward-compatible. For example, PowerShell 2.0 will generally work in Windows PowerShell 5.0 without changes.

Remember to check if your installed products support PowerShell version 5, but my personal recommendation is update to Windows 10, which has PowerShell version 5 built-in by default.

For more information about how upgrade to windows 10 works, access this website https://technet.microsoft.com/en-us/itpro/windows/deploy/windows-10-deployment-scenarios

2. What is the order to execute a command?

If you have an alias and a cmdlet with the same name and execute it in the wrong order, you will likely get a wrong execution. This is because we have rules called command precedence.

The order for this precedence is as follows:

1. Full path

2. Alias

3. Function

4. Cmdlet (command let)

5. External commands

In case you are not aware of this terminology, here is a quick recap:

An alias is a nickname for a cmdlet or for a command element, such as a function, script, file, or executable file

A function is a list of commands that has a name that you assign. It can work like a cmdlet, but you create it yourself.

In the example below,

Normally, when you type ping, you use ping.exe and it works like this:

clip_image002[4]

But now, just for test, you set ping to work like get-process, it´s happen because an alias has precedence on external command.

clip_image004[4]

You can find more information by using the command get-help about_command_precedence or on https://technet.microsoft.com/en-us/library/hh848304.aspx . It includes best practice recommendations on using scripts to expand all aliases.

3. What exactly are providers and how can I use them?

Ok it’s two question, but let’s go. Providers are a way to work like folders, but while you are working with other data such as registry, certificates, Active Directory and IIS. For example, I need to get windows time services information:

cd HKLM:\SYSTEM\CurrentControlSet\Services\w32time

dir

Remember cd is an alias to set-location and dir is an alias to get-childitem

More information about providers can be found by typing get-help about_providers or by visiting online at https://technet.microsoft.com/en-us/library/hh847791.aspx

4. Do I need to enable PowerShell remote on windows server 2012 r2?

The fast answer is no. In Windows Server 2012 R2 the PowerShell remoting is enabled by default. In order to use it, we need the following:

· The winRM service is running.

· WSman has an HTTP listener configured.

· Inbound firewall rule for port 5985 is enabled

Friendly reminder, for Windows client (7,8,8.1 or 10) remoting is disabled by default, you have use GPO or enable-psremoting to configure it, you can check the step by step on Ed Wilson (scripting guy) blog, https://blogs.technet.microsoft.com/heyscriptingguy/2012/07/24/an-introduction-to-powershell-remoting-part-two-configuring-powershell-remoting/

5. I keep hearing about DSC from DevOps. What is DSC?

Desired State Configuration is a new way to configure servers and maintain server side configuration across all virtual machine lifecycles. If you’re curious about DSC, check out one of our earlier posts on DSC training at: https://blogs.technet.microsoft.com/askpfeplat/2016/02/22/dsc-for-the-pfe-a-training-montage/.

If you want to know more about PowerShell, you can use this free course at MVA (https://aka.ms/MVAPSAD), or you can attend a premier WorkshopPLUS – Windows PowerShell v4.0 for the IT Professional – Part 1(https://aka.ms/wkspsv4p1). For the workshop you do need to have a Microsoft Premier contract. For more information about workshops, talk with your TAM or Microsoft contact, and tell them Thiago sent you.

See you guys,

Thiago Cardoso