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)

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

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/

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

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/