Monthly Archives: July 2014

QuickTip: Determine if current PowerShell session is 64bit

Occasionally it might be interesting to know whether your current PowerShell session is running in 64-bit. This tip describes how to determine this and how to start either a 32 or 64-bit session of PowerShell. To quickly determine if you current PowerShell session is 32 or 64-bit use the following code:

[System.IntPtr]::Size

There are two possible results from this code:

  • 4 – x86
  • 8 – x64

Keep this in mind, especially if you intend to execute memory dependent tasks in Powershell, the testing if the script is executing in a 64 bit context is a good idea.

If a system is 64-bit the following two paths are available for the PowerShell executable:

  • C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\powershell.exe (32-bit)
  • C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe (64-bit)
Share

New article on PowerShell Magazine: Show friendly GPO names with Get-ADOrganizationalUnit

Today’s tip is on how to use the Get-OUWithGPOLink funtion in combination with the Get-ADOrganizationalUnit cmdlet. The output of ADOrganizational unit is updated with a new property, FriendlyGPODisplayName. The article is available on PowerShell Magazine:

http://www.powershellmagazine.com/2014/07/25/pstip-show-friendly-gpo-names-with-get-adorganizationalunit/

The full script is also available in the TechNet Script Gallery, Get-OUWithGPO.ps1, at the following link:
http://gallery.technet.microsoft.com/Get-OUWithGPOLinks-List-02bfe340

Share

New article on PowerShell Magazine: Select non-administrative shared folders using Win32_Share WMI class

Today’s tip is on how to use the Type property of the Win32_Share class to select only non-administrative shares from a local or remote system. This class can be used in combination with the Get-WmiObject or Get-CimInstance cmdlets to gather this data. The examples in this articles show how this can be used against a remote system. The article is available on PowerShell Magazine:

http://www.powershellmagazine.com/2014/07/24/pstip-select-non-administrative-shared-folders-using-win32_share-wmi-class/

Share

New article on PowerShell Magazine: Enumerating mapped network drives using WScript.Network

The Wscript.Network COM object offers a variety of useful methods, in a previous tip I showed how to map a network drive and how to remove a mapped network drive. Today the EnumNetworkDrives method will be used to enumerate the currently mapped network drives. A tip on how to enumerate mapped network drives using the EnumNetworkDrives method is available on PowerShell Magazine:

http://www.powershellmagazine.com/2014/07/23/pstip-enumerating-mapped-network-drives-using-wscript-network/

For this article I have written a script that converts the output from this method into PowerShell objects. The script, Get-MappedDrive, is available in the Technet Script Gallery:
http://gallery.technet.microsoft.com/Get-MappedDrive-Get-list-f454b048

Share

New article on PowerShell Magazine: Rename a local or a mapped drive using Shell.Application

In PowerShell it is possible to rename mapped network drives and local disk drives. This can be achieved by using the Shell.Application class. A tip on how to rename a drive using this method has been posted on PowerShell Magazine:

http://www.powershellmagazine.com/2014/07/22/pstip-rename-a-local-or-a-mapped-drive-using-shell-application/

Share

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