Unblocking Files downloaded from the Internet

First off, make sure you trust the source of where you downloaded the files from, only download from legitimate sites you trust and check the SSL certificate if needs be.

Browse to the excellent Sysinternals page on Microsoft’s technet site. Right click the Download Sysinternals Suite link and select “Save link as…” and choose a location to save it to your PC.

If you were to right click on the download zip file and extract the contents and run the programs or view the help files, you will get the Open File – Security Warning dialogue box pop up each time you run it and the help files will not have any contents.

Open File Security Warning
Open File Security Warning

To remove this warning (you of course got the file(s) from a trustworthy source), you can right click on the downloaded zip file, select “Properties”, check the “Unblock” checkbox and click apply. When you extract the zip file, all the files will be unblocked.

unblock a file
Unblock a file

To do this in PowerShell use the Unblock-File command.

This will have the same effect checking the Unblock checkbox.

If you’ve already extracted the files and forgot to unblock them, use the PowerShell command again with the path to the folder containing the files with \* on the end.

 

Azure PowerShell login and create resource group

I’ve been doing lots of work with Azure recently (especially using PowerShell) so thought I’d dump some of the stuff I’ve learnt along the way here… it’s been a while.

This small guide will show you how to login to Azure using PowerShell, view and select your subscriptions and then create a Resource Group that will be provisioned in the Azure Portal.

I’ve messed about with the classic portal a bit, but Resource Manager (RM) is the way to go… you’ll see Rm in the PowerShell nouns to signify that it is a Resource Manager cmdlet.

First you need to install Azure PowerShell to get all that Azure PowerShell goodness… once you’re done (the instructions are clear and easy to follow) come back here and continue below.

Login to your Azure RM account

Get Azure RM subscriptions

Set your Azure RM subscription to work in (one of mine is called Pay-As-You-Go)

Create an Azure RM resource group

This creates a Resource Group called ps-test in the North Europe region with the tag “Created By Matt”

Go to the portal and you should see the newly created resource group (make sure you have selected the correct subscription if you have more than one).

Azure Resource Group deployed by PowerShell
Azure Portal

 

Tags are great and an excellent way to organise your resources, you can also use them to report on costs and usage.

That’s a simple demo of login into Azure with PowerShell, selecting a subscription and then deploying a resource group which is used as a container to help keep track of resources for VMs, Apps, Databases etc.

PowerShell Remoting WinRM

When trying to enter a PowerShell session on a remote PC

you receive the following error:

Enter-PSSession : Connecting to remote server win7-pc01 failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:1 + Enter-PSSession win7-pc01 + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (win7-pc01:String) [Enter-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

Go to the client computer and check to see if the WinRM service is running.

Status Name DisplayName ------ ---- ----------- Running WinDefend Windows Defender Running WinHttpAutoProx... WinHTTP Web Proxy Auto-Discovery Se... Running Winmgmt Windows Management Instrumentation Stopped WinRM Windows Remote Management (WS-Manag...

We need to start the WinRM service, run:

After that has completed, check the service is running by:

PS C:\> Start-Service -Name WinRM -Verbose VERBOSE: Performing operation "Start-Service" on Target "Windows Remote Management (WS-Management) (WinRM)". PS C:\> Get-Service -Name WinRM  Status   Name               DisplayName ------   ----               ----------- Running  WinRM              Windows Remote Management (WS-Manag...

Now we have to configure WinRM to recieve remote requested. Run:

Answer Y to the questions. You’ll set the service to start when the PC is booted up, create a listener to “listen” for WinRM requests and configure the Windows firewall to allow the WinRM traffic.

WinRM quickconfig

If you check your inbound connections on your firewall you’ll see the new rules added.
WinRM firewall settings after running winrm quickconfig

We should now be able to remotely connect to the client PC via PowerShell and run all the PowerShell commands on it:

PS C:\> Enter-PSSession -ComputerName win7-pc01 [win7-pc01]: PS C:\Users\administrator\Documents>

Hope this has helped.

Please note
This was done on my test network. Make sure you know the implications of opening up firewall ports and running WinRM on you PC(s).

For this post my test lab consists of a Windows Server 2012 R2 GC DC and a Windows 7 Enterprise client.