Monthly Archives: July 2014

PowerShell DSC Resource Kit Wave 5 has been released

Today the PowerShell team announced that the latest iteration of their Desired State Configuration Resource Kit has been released. This is an experimental resource that is intended for lab and testing purposes. The latest version is available in the Technet Script Gallery:

DSC Resource Kit (All Modules)

Depending on which modules you will be using this resource kit either requires Server 2012 R2/Windows 8.1 with PowerShell 4.0. The xJEA module requires installation of the Windows Management Framework 5.0 Preview.

The original announcement by the PowerShell Team is available here:
PowerShell DSC Resource Kit Wave 5 Arrives

Share

New article on PowerShell Magazine: Create mapped network drive using WScript.Network

In PowerShell there are several methods available to created mapped drives, one of these is by using the MapNetworkDrive method of Wscript.Network COM object. A tip on how to map a drive using this method which also includes how to remove the mapped folder is available on PowerShell Magazine:

http://www.powershellmagazine.com/2014/07/21/pstip-create-mapped-network-drive-using-wscript-network/

This article and many other articles I have written for other websites are available in the External Articles section of this blog.

Share

Setting up PowerShell Remoting using winrm quickconfig or Enable-PSRemoting fails

A common problem on laptops or mobile workstations is that the initial PowerShell Remoting configuration will fail because the system is connected to a public network. The advice is to change the network from public to private, unfortunately this is not always possible because of WiFi connections.

There is a work around available for this, by running the following code:

Enable-PSRemoting -SkipNetworkProfileCheck -Force

By including the -SkipNetworkProfileCheck the cmdlet with omit the network check and PowerShell remoting correctly regardless of the fact that the system might be connected to a public network.

When setting up PowerShell Remoting using winrm quickconfig the following error might occur:

PS C:\WINDOWS\system32> winrm quickconfig  quests on this machine.
The following changes must be made:

Start the WinRM service.
Set the WinRM service type to delayed auto start.

Make these changes [y/n]? y

WinRM has been updated to receive requests.

WinRM service type changed successfully.
WinRM service started.
WSManFault
Message
ProviderFault
WSManFault
Message = WinRM firewall exception will not work since one of the network connection types on this machi
ne is set to Public. Change the network connection type to either Domain or Private and try again.

Error number: -2144108183 0x80338169
WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Chang
e the network connection type to either Domain or Private and try again.

Or when using Enable-PSRemoting without skip network check this error will appear:

PS C:\WINDOWS\system32> Enable-PSRemoting -force

Set-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859113"
Machine="localhost"><f:Message><f:ProviderFault provider="Config provider"
path="%systemroot%\system32\WsmSvc.dll"><f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault"
Code="2150859113" Machine="computername"><f:Message>WinRM firewall exception will not work since one of the network
connection types on this machine is set to Public. Change the network connection type to either Domain or Private and
try again. </f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
At line:69 char:17
+ Set-WSManQuickConfig -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand
Share

QuickTip: Using Win32_Share to only select non-default shares

The Win32_Share class can be used to remotely or locally gather a listed of shared folders and their properties. Since every Windows system by default has a number of standard shared folder it can be interesting to only select the non-default shares. The following line of code allows you to do that:

Get-WmiObject Win32_Share | Where-Object {(@('Remote Admin','Default share','Remote IPC') -notcontains $_.Description)}

Note that this only works for systems with English localization options. For other languages the names in the array will have to be changed to match to localized names.

Share

Update to Connect-Mstsc script, RDP Session with credentials

A request came in for additional functional of my Connect-Mstsc script and I decided to add the -Admin parameter to this script. I have published the latest version of this script at the Technet Script Gallery:

Connect-Mstsc – Open RDP Session with credentials

Here are some example of how the script can be used:

.EXAMPLE    
. .\Connect-Mstsc.ps1 
     
Description  
-----------      
This command dot sources the script to ensure the Connect-Mstsc function is available in your current PowerShell session 
 
.EXAMPLE    
Connect-Mstsc -ComputerName server01 -User contoso\jaapbrasser -Password supersecretpw 
Description 
----------- 
A remote desktop session to server01 will be created using the credentials of contoso\jaapbrasser
Share