PowerShell FAQ: Top 5 Questions about PowerShell from the Field

___________________________________________________________________________________________________________________________

IMPORTANT ANNOUNCEMENT FOR OUR READERS!

AskPFEPlat is in the process of a transformation to the new Core Infrastructure and Security TechCommunity, and will be moving by the end of March 2019 to our new home at https://aka.ms/CISTechComm (hosted at https://techcommunity.microsoft.com). Please bear with us while we are still under construction!

We will continue bringing you the same great content, from the same great contributors, on our new platform. Until then, you can access our new content on either https://aka.ms/askpfeplat as you do today, or at our new site https://aka.ms/CISTechComm. Please feel free to update your bookmarks accordingly!

Why are we doing this? Simple really; we are looking to expand our team internally in order to provide you even more great content, as well as take on a more proactive role in the future with our readers (more to come on that later)! Since our team encompasses many more roles than Premier Field Engineers these days, we felt it was also time we reflected that initial expansion.

If you have never visited the TechCommunity site, it can be found at https://techcommunity.microsoft.com. On the TechCommunity site, you will find numerous technical communities across many topics, which include discussion areas, along with blog content.

NOTE: In addition to the AskPFEPlat-to-Core Infrastructure and Security transformation, Premier Field Engineers from all technology areas will be working together to expand the TechCommunity site even further, joining together in the technology agnostic Premier Field Engineering TechCommunity (along with Core Infrastructure and Security), which can be found at https://aka.ms/PFETechComm!

As always, thank you for continuing to read the Core Infrastructure and Security (AskPFEPlat) blog, and we look forward to providing you more great content well into the future!

__________________________________________________________________________________________________________________________

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