Wednesday, June 29, 2011

Find your VMware local VMFS datastore with powershell

To find your local VMFS datastore

Solution 1: name all your local vmfs LOCAL_xxx
Get all your local datastore by using
Get-Datastore | Get-View | Where-Object { $_.Name -match "LOCAL_*" } | Select-Object  @{n="Name";e={$_.Name}}}

Name
----
LOCAL_ESX01
LOCAL_ESX02
LOCAL_ESX03



Solution 2: use MultipleHostAccess info from Get-Datastore
(Thanks to http://blogs.vmware.com/vipowershell/2009/08/how-to-list-datastores-that-are-on-shared-storage.html?cid=6a00d8341c328153ef0120a52e7f0b970b for MultipleHostAccess tip)
You can use this:
Get-Datastore | Get-View | Select-Object  @{n="Name";e={$_.Name}}, @{n="San_Nas";e={$_.Summary.MultipleHostAccess}}

Name San_Nas
---- -------
NFS_VOL2 True
LOCAL_ESX01 False
NFS_VOL1 True
LOCAL_ESX02 False
LOCAL_ESX03 False



Solution 3: use Vendor / Model SCSILun informations from VMHost get-view
Get-VMHost | Get-View | Foreach-Object { $vmhost=$_.Name; $_.Config.StorageDevice.ScsiLun |  Select-Object @{n="Hostname";e={$vmhost}},@{n="Model";e={$_.Model}},@{n="Vendor";e={$_.Vendor}} }


Hostname Model Vendor
-------- ----- ------
esx01 LOGICAL VOLUME HP
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx01 SYMMETRIX EMC
esx02 RAID 5 DGC
esx02 SYMMETRIX EMC
esx02 SYMMETRIX EMC
esx02 RAID 5 DGC
esx03 LOGICAL VOLUME HP
esx03 2810XIV IBM
esx03 2810XIV IBM
esx03 2810XIV-LUN-0 IBM
esx03 2810XIV IBM



Example of SAN vendor/model
Vendor / Model
VMware / Block device
EMC / SYMMETRIX
IBM / 2810XIV

Example of Local storage
Vendor / Model
HP / LOGICAL VOLUME
DGC / RAID 5

Friday, June 17, 2011

Optimize your vmware powershell: part 1 - Get-Datacenter

Remember Get-Datacenter | Get-View = Get-View -ViewType Datacenter
For better performance, use
Get-View -ViewType
Use "-Property property1,property2,property3" switch if you don't need all properties. Less data to take = better performance too.

Execution time results after the execution of some commands:

Command

seconds

Get-View -ViewType Datacenter -Property Name

0,093652985

Get-View -ViewType Datacenter

0,128286732

Get-Datacenter

0,190378198

Get-Datacenter | Get-View

0,241663792

Get-View -ViewType Datacenter -Property Name | Foreach-Object { Get-VIObjectByVIView $_.MoRef }

0,296987547

Get-View -ViewType Datacenter | Foreach-Object { Get-VIObjectByVIView $_.MoRef

0,342440257



Get-Datastore fields and its equivalent fields with Get-View

Command

Equivalent Fields

$dc0 = Get-Datacenter | Where-Object { $_.Name -eq "Datacenter_1" }

$dc1 = Get-View -ViewType Datacenter | Where-Object { $_.Name -eq "Datacenter_1" }

$dc0.ExtensionData

$dc1

$dc0.Name

$dc1.Name

$dc0.Id

$dc1.MoRef

$dc0.ParentFolderId

$dc1.Parent

$dc0.CustomFields

[Array] $arrFields = @()
$dc1 | Foreach-Object {
$datacenter = $_
$datacenter.AvailableField | Foreach-Object {
$availablefield = $_
$Key = $availablefield.Name
$Value = ($datacenter.CustomValue | Where-Object { $_.Key -eq $availablefield.Key}).Value

$objParent = New-Object PSObject
$objParent | Add-Member -MemberType noteproperty -Name "Key" -Value $key
$objParent | Add-Member -MemberType noteproperty -Name "Value" -Value $value
$arrFields += $objParent
}
}

$arrFields

Another way to improve your scripts: use -Filter switch when you want specific data. Some lines can also be better than 1 cmdlets , but it's not always the case (see below)

Command

seconds

#Equivalent

#Get-Datacenter -Name Datacenter_2

Get-View -ViewType Datacenter -Filter @{"Name"="Datacenter_2"}

0,11421332

#Equivalent

#Get-Datacenter -Name Datacenter_2

Get-View -ViewType Datacenter | Where-Object { $_.Name -eq "Datacenter_2" }

0,13915101

Get-Datacenter -Name Datacenter_2

0,18590567

Get-Datacenter -Id Datacenter-datacenter-3472

0,18141816

Get-Datacenter -Cluster Cluster_2

0,37470311

#Equivalent

# Get-Datacenter -Cluster Cluster_2

$cluster=" Cluster_2"

$parent = (Get-View -ViewType ComputeResource -Filter @{"Name"=$cluster} -Property Parent).Parent.ToString()

While ($parent.ToString().Substring(0,5).ToUpper() -ne "DATAC") {

$parent = (Get-View -ViewType Folder -Property Parent | Where-Object { $_.MoRef.ToString() -eq $parent}).Parent.ToString()

}

Get-Datacenter -Id $parent

0,4999502

Get-Datacenter -VMHost ESX01

0,8159789

#Equivalent

# Get-Datacenter -VMHost ESX01

$parent = (Get-View -ViewType HostSystem -Filter @{"Name"=" ESX01"} -Property Parent).Parent.ToString()

If ($parent.ToString().Substring(0,5).ToUpper() -eq "CLUST") {

$parent = (Get-View -ViewType ComputeResource -Property Parent | Where-Object { $_.MoRef.ToString() -eq $parent}).Parent.ToString()

}

While ($parent.ToString().Substring(0,5).ToUpper() -ne "DATAC") {

$parent = (Get-View -ViewType Folder -Property Parent | Where-Object { $_.MoRef.ToString() -eq $parent}).Parent.ToString()

}

Get-Datacenter -Id $parent

0,7234534

#Equivalent

# Get-Datacenter -VM VM01

$vm=" VM01"

$parent = (Get-View -ViewType VirtualMachine -Filter @{"Name"=$vm} -Property Parent).Parent.ToString()

While ($parent.ToString().Substring(0,5).ToUpper() -ne "DATAC") {

$parent = (Get-View -ViewType Folder -Property Parent | Where-Object { $_.MoRef.ToString() -eq $parent}).Parent.ToString()

}

Get-Datacenter -Id $parent

0,6182902

Get-Datacenter -VM VM01

5,26492918



Some cmdlets result properties

[vSphere PowerCLI]> Get-Datacenter | select *

ParentFolderId : Folder-group-d1
ParentFolder : Datacenters
CustomFields : {}
ExtensionData : VMware.Vim.Datacenter
Id : Datacenter-datacenter-3472
Name : Datacenter_2
Uid : /VIServer=@localhost:443/Datacenter=Datacenter-datacenter-3472/

ParentFolderId : Folder-group-d1
ParentFolder : Datacenters
CustomFields : {}
ExtensionData : VMware.Vim.Datacenter
Id : Datacenter-datacenter-10
Name : Datacenter_1
Uid : /VIServer=@localhost:443/Datacenter=Datacenter-datacenter-10/


[vSphere PowerCLI]> Get-View -ViewType Datacenter


VmFolder : Folder-group-v11
HostFolder : Folder-group-h12
DatastoreFolder :
NetworkFolder :
Datastore : {Datastore-datastore-123, Datastore-datastore-233, Datastore-datastore-235, Datastore-datastore-237...}
Network : {Network-network-1634, Network-network-1636, Network-network-6006, Network-network-3456...}
Parent : Folder-group-d1
CustomValue : {}
OverallStatus : gray
ConfigStatus : gray
ConfigIssue : {}
EffectiveRole : {-1}
Permission : {113, 113, -5, -2...}
Name : Datacenter_1
DisabledMethod : {}
RecentTask : {}
DeclaredAlarmState : {alarm-1.datacenter-10, alarm-2.datacenter-10, alarm-3.datacenter-10, alarm-4.datacenter-10...}
TriggeredAlarmState : {alarm-3.host-184, alarm-3.host-3310, alarm-3.host-3834, alarm-3.host-5972...}
AlarmActionsEnabled : False
Tag :
Value : {}
AvailableField : {}
MoRef : Datacenter-datacenter-10
Client : VMware.Vim.VimClient

VmFolder : Folder-group-v3473
HostFolder : Folder-group-h3474
DatastoreFolder :
NetworkFolder :
Datastore : {Datastore-datastore-3554, Datastore-datastore-3556, Datastore-datastore-3558, Datastore-datastore-3560...}
Network : {Network-network-9660, Network-network-6759, Network-network-6761, Network-network-6760...}
Parent : Folder-group-d1
CustomValue : {}
OverallStatus : gray
ConfigStatus : gray
ConfigIssue : {}
EffectiveRole : {-1}
Permission : {107, 107, 107, 107...}
Name : Datacenter_2
DisabledMethod : {}
RecentTask : {}
DeclaredAlarmState : {alarm-1.datacenter-3472, alarm-2.datacenter-3472, alarm-3.datacenter-3472, alarm-4.datacenter-3472...}
TriggeredAlarmState : {alarm-3.host-11857, alarm-3.host-11873, alarm-3.host-6439, alarm-4.vm-9648}
AlarmActionsEnabled : False
Tag :
Value : {}
AvailableField : {}
MoRef : Datacenter-datacenter-3472
Client : VMware.Vim.VimClient

[vSphere PowerCLI]> Get-Datacenter | Where-Object { $_.Name -eq "Datacenter_1" } | Get-Member

TypeName: VMware.VimAutomation.ViCore.Impl.V1.Inventory.DatacenterImpl

Name MemberType Definition
---- ---------- ----------
ConvertToVersion Method ConvertToVersion()
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetHostFolder Method VMware.VimAutomation.ViCore.Interop.V1.Inventory.FolderInterop GetHostFolder()
GetType Method System.Type GetType()
GetVmFolder Method VMware.VimAutomation.ViCore.Interop.V1.Inventory.FolderInterop GetVmFolder()
get_CustomFields Method System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] get_CustomFields()
get_ExtensionData Method System.Object get_ExtensionData()
get_Id Method System.String get_Id()
get_Name Method System.String get_Name()
get_ParentFolder Method VMware.VimAutomation.ViCore.Types.V1.Inventory.Folder get_ParentFolder()
get_ParentFolderId Method System.String get_ParentFolderId()
get_Uid Method System.String get_Uid()
IsConvertableTo Method System.Boolean IsConvertableTo(Type toType)
ToString Method System.String ToString()
CustomFields Property System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] CustomFields {get;}
ExtensionData Property System.Object ExtensionData {get;}
Id Property System.String Id {get;}
Name Property System.String Name {get;}
ParentFolder Property VMware.VimAutomation.ViCore.Types.V1.Inventory.Folder ParentFolder {get;}
ParentFolderId Property System.String ParentFolderId {get;}
Uid Property System.String Uid {get;}

[vSphere PowerCLI]>Get-View -ViewType Datacenter | Where-Object { $_.Name -eq "Datacenter_1"   } | Get-Member

TypeName: VMware.Vim.Datacenter

Name MemberType Definition
---- ---------- ----------
Destroy Method System.Void Destroy()
Destroy_Task Method VMware.Vim.ManagedObjectReference Destroy_Task()
Equals Method System.Boolean Equals(Object obj)
GetAllEventsView Method VMware.Vim.EventHistoryCollector GetAllEventsView(EventFilterSpec eventFilterSpec)
GetAllTasksView Method VMware.Vim.TaskHistoryCollector GetAllTasksView(TaskFilterSpec taskFilterSpec)
GetEntityOnlyEventsCollectorView Method VMware.Vim.EventHistoryCollector GetEntityOnlyEventsCollectorView(EventFilterSpec eventFilterSpec)
GetEntityOnlyTasksCollectorView Method VMware.Vim.TaskHistoryCollector GetEntityOnlyTasksCollectorView(TaskFilterSpec taskFilterSpec)
GetEventCollectorView Method VMware.Vim.EventHistoryCollector GetEventCollectorView(EventFilterSpecRecursionOption recursionOption, EventFilterSpec eventFilterSpec)
GetHashCode Method System.Int32 GetHashCode()
GetTaskCollectorView Method VMware.Vim.TaskHistoryCollector GetTaskCollectorView(TaskFilterSpecRecursionOption recursionOption, TaskFilterSpec taskFilterSpec)
GetType Method System.Type GetType()
get_AlarmActionsEnabled Method System.Boolean get_AlarmActionsEnabled()
get_AvailableField Method VMware.Vim.CustomFieldDef[] get_AvailableField()
get_Client Method VMware.Vim.VimClient get_Client()
get_ConfigIssue Method VMware.Vim.Event[] get_ConfigIssue()
get_ConfigStatus Method VMware.Vim.ManagedEntityStatus get_ConfigStatus()
get_CustomValue Method VMware.Vim.CustomFieldValue[] get_CustomValue()
get_Datastore Method VMware.Vim.ManagedObjectReference[] get_Datastore()
get_DatastoreFolder Method VMware.Vim.ManagedObjectReference get_DatastoreFolder()
get_DeclaredAlarmState Method VMware.Vim.AlarmState[] get_DeclaredAlarmState()
get_DisabledMethod Method System.String[] get_DisabledMethod()
get_EffectiveRole Method System.Int32[] get_EffectiveRole()
get_HostFolder Method VMware.Vim.ManagedObjectReference get_HostFolder()
get_MoRef Method VMware.Vim.ManagedObjectReference get_MoRef()
get_Name Method System.String get_Name()
get_Network Method VMware.Vim.ManagedObjectReference[] get_Network()
get_NetworkFolder Method VMware.Vim.ManagedObjectReference get_NetworkFolder()
get_OverallStatus Method VMware.Vim.ManagedEntityStatus get_OverallStatus()
get_Parent Method VMware.Vim.ManagedObjectReference get_Parent()
get_Permission Method VMware.Vim.Permission[] get_Permission()
get_RecentTask Method VMware.Vim.ManagedObjectReference[] get_RecentTask()
get_Tag Method VMware.Vim.Tag[] get_Tag()
get_TriggeredAlarmState Method VMware.Vim.AlarmState[] get_TriggeredAlarmState()
get_Value Method VMware.Vim.CustomFieldValue[] get_Value()
get_VmFolder Method VMware.Vim.ManagedObjectReference get_VmFolder()
PowerOnMultiVM Method VMware.Vim.ClusterPowerOnVmResult PowerOnMultiVM(ManagedObjectReference[] vm, OptionValue[] option)
PowerOnMultiVM_Task Method VMware.Vim.ManagedObjectReference PowerOnMultiVM_Task(ManagedObjectReference[] vm, OptionValue[] option)
QueryConnectionInfo Method VMware.Vim.HostConnectInfo QueryConnectionInfo(String hostname, Int32 port, String username, String password, String sslThumbprint)
Reload Method System.Void Reload()
Rename Method System.Void Rename(String newName)
Rename_Task Method VMware.Vim.ManagedObjectReference Rename_Task(String newName)
setCustomValue Method System.Void setCustomValue(String key, String value)
SetViewData Method System.Void SetViewData(ObjectContent objectContent, String[] properties)
ToString Method System.String ToString()
UpdateViewData Method System.Void UpdateViewData(Params String[] properties), System.Void UpdateViewData()
WaitForTask Method System.Object WaitForTask(ManagedObjectReference taskReference)
AlarmActionsEnabled Property System.Boolean AlarmActionsEnabled {get;}
AvailableField Property VMware.Vim.CustomFieldDef[] AvailableField {get;}
Client Property VMware.Vim.VimClient Client {get;}
ConfigIssue Property VMware.Vim.Event[] ConfigIssue {get;}
ConfigStatus Property VMware.Vim.ManagedEntityStatus ConfigStatus {get;}
CustomValue Property VMware.Vim.CustomFieldValue[] CustomValue {get;}
Datastore Property VMware.Vim.ManagedObjectReference[] Datastore {get;}
DatastoreFolder Property VMware.Vim.ManagedObjectReference DatastoreFolder {get;}
DeclaredAlarmState Property VMware.Vim.AlarmState[] DeclaredAlarmState {get;}
DisabledMethod Property System.String[] DisabledMethod {get;}
EffectiveRole Property System.Int32[] EffectiveRole {get;}
HostFolder Property VMware.Vim.ManagedObjectReference HostFolder {get;}
MoRef Property VMware.Vim.ManagedObjectReference MoRef {get;}
Name Property System.String Name {get;}
Network Property VMware.Vim.ManagedObjectReference[] Network {get;}
NetworkFolder Property VMware.Vim.ManagedObjectReference NetworkFolder {get;}
OverallStatus Property VMware.Vim.ManagedEntityStatus OverallStatus {get;}
Parent Property VMware.Vim.ManagedObjectReference Parent {get;}
Permission Property VMware.Vim.Permission[] Permission {get;}
RecentTask Property VMware.Vim.ManagedObjectReference[] RecentTask {get;}
Tag Property VMware.Vim.Tag[] Tag {get;}
TriggeredAlarmState Property VMware.Vim.AlarmState[] TriggeredAlarmState {get;}
Value Property VMware.Vim.CustomFieldValue[] Value {get;}
VmFolder Property VMware.Vim.ManagedObjectReference VmFolder {get;}

Sunday, June 5, 2011

GetSpecialFolderPath in Powershell

To complete "Enumerate your own enum in Powershell" post, I give you this below script to use GetSpecialFolderPath
(Download it)
You can remove # comment in this script if you need to see some examples of array or hashtable use


#
#
# GetSpecialFolderPath
#
# by F.Richard 2011-05
#
#

#Requires -Version 2.0


# CSIDL
# http://msdn.microsoft.com/en-us/library/bb762494%28v=vs.85%29.aspx
# for windows XP and later OS
# KNOWNFOLDERID
# http://msdn.microsoft.com/en-us/library/dd378457%28v=vs.85%29.aspx
# for Vista and later OS
# Recognized Environment Variables
# http://technet.microsoft.com/en-us/library/cc749104%28WS.10%29.aspx

# DllImport
$signature = @"
[DllImport("Shell32.dll")]
public static extern int SHGetSpecialFolderPath(UIntPtr hwndOwner, System.Text.StringBuilder lpszPath, CSIDL iCsidl, int fCreate);


public enum CSIDL : int {
CSIDL_DESKTOP = 0x0000,
CSIDL_INTERNET = 0x0001,
CSIDL_PROGRAMS = 0x0002,
CSIDL_CONTROLS = 0x0003,
CSIDL_PRINTERS = 0x0004,
CSIDL_PERSONAL = 0x0005,
CSIDL_FAVORITES = 0x0006,
CSIDL_STARTUP = 0x0007,
CSIDL_RECENT = 0x0008,
CSIDL_SENDTO = 0x0009,
CSIDL_BITBUCKET = 0x000a,
CSIDL_STARTMENU = 0x000b,
CSIDL_MYDOCUMENTS = CSIDL_PERSONAL,
CSIDL_MYMUSIC = 0x000d,
CSIDL_MYVIDEO = 0x000e,
CSIDL_DESKTOPDIRECTORY = 0x0010,
CSIDL_DRIVES = 0x0011,
CSIDL_NETWORK = 0x0012,
CSIDL_NETHOOD = 0x0013,
CSIDL_FONTS = 0x0014,
CSIDL_TEMPLATES = 0x0015,
CSIDL_COMMON_STARTMENU = 0x0016,
CSIDL_COMMON_PROGRAMS = 0x0017,
CSIDL_COMMON_STARTUP = 0x0018,
CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019,
CSIDL_APPDATA = 0x001a,
CSIDL_PRINTHOOD = 0x001b,
CSIDL_LOCAL_APPDATA = 0x001c,
CSIDL_ALTSTARTUP = 0x001d,
CSIDL_COMMON_ALTSTARTUP = 0x001e,
CSIDL_COMMON_FAVORITES = 0x001f,
CSIDL_INTERNET_CACHE = 0x0020,
CSIDL_COOKIES = 0x0021,
CSIDL_HISTORY = 0x0022,
CSIDL_COMMON_APPDATA = 0x0023,
CSIDL_WINDOWS = 0x0024,
CSIDL_SYSTEM = 0x0025,
CSIDL_PROGRAM_FILES = 0x0026,
CSIDL_MYPICTURES = 0x0027,
CSIDL_PROFILE = 0x0028,
CSIDL_SYSTEMX86 = 0x0029,
CSIDL_PROGRAM_FILESX86 = 0x002a,
CSIDL_PROGRAM_FILES_COMMON = 0x002b,
CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c,
CSIDL_COMMON_TEMPLATES = 0x002d,
CSIDL_COMMON_DOCUMENTS = 0x002e,
CSIDL_COMMON_ADMINTOOLS = 0x002f,
CSIDL_ADMINTOOLS = 0x0030,
CSIDL_CONNECTIONS = 0x0031,
CSIDL_COMMON_MUSIC = 0x0035,
CSIDL_COMMON_PICTURES = 0x0036,
CSIDL_COMMON_VIDEO = 0x0037,
CSIDL_RESOURCES = 0x0038,
CSIDL_RESOURCES_LOCALIZED = 0x0039,
CSIDL_COMMON_OEM_LINKS = 0x003a,
CSIDL_CDBURN_AREA = 0x003b,
CSIDL_COMPUTERSNEARME = 0x003d,
CSIDL_FLAG_CREATE = 0x8000,
CSIDL_FLAG_DONT_VERIFY = 0x4000,
CSIDL_FLAG_DONT_UNEXPAND = 0x2000,
CSIDL_FLAG_NO_ALIAS = 0x1000,
CSIDL_FLAG_PER_USER_INIT = 0x0800
}
"@



# Register shell32 functions
If (-not ("Shell32.Tools" -as [Type])) {
$type = Add-Type -MemberDefinition $signature -Name Tools -Namespace Shell32 -Using System.Text -PassThru
} else {
If ($debug) { Write-Host "Shell32.Tools already Registered" }
}
# Get Common Desktop Directory
$hwnd = New-Object UIntPtr
$lpData = New-Object System.Text.StringBuilder(260) # MAX_PATH = 256
$CSIDL = "CSIDL_COMMON_DESKTOPDIRECTORY"
if([Shell32.Tools]::SHGetSpecialFolderPath($hwnd, $lpData, $CSIDL, 0)) {
Write-Host $CSIDL "=" $lpData
}


# Enum To Array
$arrEnum=[Enum]::GetNames([Shell32.Tools+CSIDL])
# Remove remark to display name and value
#foreach ($name in $arrEnum) {
# Write-Host "Name:$name Value:"([Shell32.Tools+CSIDL]::$name).value__
#}


# Enum To Hash
$hashEnum = @{ }
[Enum]::GetValues([Shell32.Tools+CSIDL])| % {$hashEnum["$_"] = $_.value__ }
# Remove remark to display name and value
#foreach ($name in $hashEnum.keys) {
# Write-Host "Name:$name Value:"$hashEnum["$name"]
#}


foreach ($CSIDL in $arrEnum) {
if ([Shell32.Tools]::SHGetSpecialFolderPath($hwnd, $lpData, $CSIDL, 0)) {
Write-Host $CSIDL "=" $lpData
}
}


Windows 2003 english example results with myuser user


C:\> .\GetSpecialFolderPath.ps1
CSIDL_COMMON_DESKTOPDIRECTORY = C:\Documents and Settings\All Users\Desktop
CSIDL_DESKTOP = C:\Documents and Settings\myuser\Desktop
CSIDL_PROGRAMS = C:\Documents and Settings\myuser\Start Menu\Programs
CSIDL_PERSONAL = C:\Documents and Settings\myuser\My Documents
CSIDL_MYDOCUMENTS = C:\Documents and Settings\myuser\My Documents
CSIDL_FAVORITES = C:\Documents and Settings\myuser\Favorites
CSIDL_STARTUP = C:\Documents and Settings\myuser\Start Menu\Programs\Startup
CSIDL_RECENT = C:\Documents and Settings\myuser\Recent
CSIDL_SENDTO = C:\Documents and Settings\myuser\SendTo
CSIDL_STARTMENU = C:\Documents and Settings\myuser\Start Menu
CSIDL_DESKTOPDIRECTORY = C:\Documents and Settings\myuser\Desktop
CSIDL_NETHOOD = C:\Documents and Settings\myuser\NetHood
CSIDL_FONTS = C:\WINDOWS\Fonts
CSIDL_TEMPLATES = C:\Documents and Settings\myuser\Templates
CSIDL_COMMON_STARTMENU = C:\Documents and Settings\All Users\Start Menu
CSIDL_COMMON_PROGRAMS = C:\Documents and Settings\All Users\Start Menu\Programs
CSIDL_COMMON_STARTUP = C:\Documents and Settings\All Users\Start Menu\Programs\Startup
CSIDL_COMMON_DESKTOPDIRECTORY = C:\Documents and Settings\All Users\Desktop
CSIDL_APPDATA = C:\Documents and Settings\myuser\Application Data
CSIDL_PRINTHOOD = C:\Documents and Settings\myuser\PrintHood
CSIDL_LOCAL_APPDATA = C:\Documents and Settings\myuser\Local Settings\Application Data
CSIDL_COMMON_FAVORITES = C:\Documents and Settings\All Users\Favorites
CSIDL_INTERNET_CACHE = C:\Documents and Settings\myuser\Local Settings\Temporary Internet Files
CSIDL_COOKIES = C:\Documents and Settings\myuser\Cookies
CSIDL_HISTORY = C:\Documents and Settings\myuser\Local Settings\History
CSIDL_COMMON_APPDATA = C:\Documents and Settings\All Users\Application Data
CSIDL_WINDOWS = C:\WINDOWS
CSIDL_SYSTEM = C:\WINDOWS\system32
CSIDL_PROGRAM_FILES = C:\Program Files
CSIDL_PROFILE = C:\Documents and Settings\myuser
CSIDL_SYSTEMX86 = C:\WINDOWS\system32
CSIDL_PROGRAM_FILES_COMMON = C:\Program Files\Common Files
CSIDL_COMMON_TEMPLATES = C:\Documents and Settings\All Users\Templates
CSIDL_COMMON_DOCUMENTS = C:\Documents and Settings\All Users\Documents
CSIDL_COMMON_ADMINTOOLS = C:\Documents and Settings\All Users\Start Menu\Programs\Administrative Tools
CSIDL_ADMINTOOLS = C:\Documents and Settings\myuser\Start Menu\Programs\Administrative Tools
CSIDL_COMMON_MUSIC = C:\Documents and Settings\All Users\Documents\My Music
CSIDL_COMMON_VIDEO = C:\Documents and Settings\All Users\Documents\My Videos
CSIDL_RESOURCES = C:\WINDOWS\resources
CSIDL_CDBURN_AREA = C:\Documents and Settings\myuser\Local Settings\Application Data\Microsoft\CD Burning
CSIDL_FLAG_PER_USER_INIT = C:\Documents and Settings\myuser\Desktop
CSIDL_FLAG_NO_ALIAS = C:\Documents and Settings\myuser\Desktop
CSIDL_FLAG_DONT_UNEXPAND = C:\Documents and Settings\myuser\Desktop
CSIDL_FLAG_DONT_VERIFY = C:\Documents and Settings\myuser\Desktop
CSIDL_FLAG_CREATE = C:\Documents and Settings\myuser\Desktop



Windows XP french example results with myuser user


c:\> .\GetSpecialFolderPath.ps1
CSIDL_COMMON_DESKTOPDIRECTORY = C:\Documents and Settings\All Users\Bureau
CSIDL_DESKTOP = C:\Documents and Settings\myuser\Bureau
CSIDL_PROGRAMS = C:\Documents and Settings\myuser\Menu Démarrer\Programmes
CSIDL_PERSONAL = D:\DONNEES
CSIDL_MYDOCUMENTS = D:\DONNEES
CSIDL_FAVORITES = C:\Documents and Settings\myuser\Favoris
CSIDL_STARTUP = C:\Documents and Settings\myuser\Menu Démarrer\Programmes\Démarrage
CSIDL_RECENT = C:\Documents and Settings\myuser\Recent
CSIDL_SENDTO = C:\Documents and Settings\myuser\SendTo
CSIDL_STARTMENU = C:\Documents and Settings\myuser\Menu Démarrer
CSIDL_MYMUSIC = D:\DONNEES\Ma musique
CSIDL_MYVIDEO = D:\DONNEES\Mes vidéos
CSIDL_DESKTOPDIRECTORY = C:\Documents and Settings\myuser\Bureau
CSIDL_NETHOOD = C:\Documents and Settings\myuser\Voisinage réseau
CSIDL_FONTS = C:\WINDOWS\Fonts
CSIDL_TEMPLATES = C:\Documents and Settings\myuser\Modèles
CSIDL_COMMON_STARTMENU = C:\Documents and Settings\All Users\Menu Démarrer
CSIDL_COMMON_PROGRAMS = C:\Documents and Settings\All Users\Menu Démarrer\Programmes
CSIDL_COMMON_STARTUP = C:\Documents and Settings\All Users\Menu Démarrer\Programmes\Démarrage
CSIDL_COMMON_DESKTOPDIRECTORY = C:\Documents and Settings\All Users\Bureau
CSIDL_APPDATA = C:\Documents and Settings\myuser\Application Data
CSIDL_PRINTHOOD = C:\Documents and Settings\myuser\Voisinage d'impression
CSIDL_LOCAL_APPDATA = C:\Documents and Settings\myuser\Local Settings\Application Data
CSIDL_COMMON_FAVORITES = C:\Documents and Settings\All Users\Favoris
CSIDL_INTERNET_CACHE = C:\Documents and Settings\myuser\Local Settings\Temporary Internet Files
CSIDL_COOKIES = C:\Documents and Settings\myuser\Cookies
CSIDL_HISTORY = C:\Documents and Settings\myuser\Local Settings\Historique
CSIDL_COMMON_APPDATA = C:\Documents and Settings\All Users\Application Data
CSIDL_WINDOWS = C:\WINDOWS
CSIDL_SYSTEM = C:\WINDOWS\system32
CSIDL_PROGRAM_FILES = C:\Program Files
CSIDL_MYPICTURES = D:\DONNEES
CSIDL_PROFILE = C:\Documents and Settings\myuser
CSIDL_SYSTEMX86 = C:\WINDOWS\system32
CSIDL_PROGRAM_FILES_COMMON = C:\Program Files\Fichiers communs
CSIDL_COMMON_TEMPLATES = C:\Documents and Settings\All Users\Modèles
CSIDL_COMMON_DOCUMENTS = C:\Documents and Settings\All Users\Documents
CSIDL_COMMON_ADMINTOOLS = C:\Documents and Settings\All Users\Menu Démarrer\Programmes\Outils d'administration
CSIDL_ADMINTOOLS = C:\Documents and Settings\myuser\Menu Démarrer\Programmes\Outils d'administration
CSIDL_COMMON_MUSIC = C:\Documents and Settings\All Users\Documents\Ma musique
CSIDL_COMMON_PICTURES = C:\Documents and Settings\All Users\Documents\Mes images
CSIDL_COMMON_VIDEO = C:\Documents and Settings\All Users\Documents\Mes vidéos
CSIDL_RESOURCES = C:\WINDOWS\resources
CSIDL_CDBURN_AREA = C:\Documents and Settings\myuser\Local Settings\Application Data\Microsoft\CD Burning
CSIDL_FLAG_PER_USER_INIT = C:\Documents and Settings\myuser\Bureau
CSIDL_FLAG_NO_ALIAS = C:\Documents and Settings\myuser\Bureau
CSIDL_FLAG_DONT_UNEXPAND = C:\Documents and Settings\myuser\Bureau
CSIDL_FLAG_DONT_VERIFY = C:\Documents and Settings\myuser\Bureau
CSIDL_FLAG_CREATE = C:\Documents and Settings\myuser\Bureau