VMware Cloud Community
jschaben
Enthusiast
Enthusiast

Creating a folder on VMFS Data Store

For several years now we have used a script as part of our build process to create a folder on a VMFS datastore for the scratch config. About 6 months ago it kind of stopped mapping properly, instead of mapping to the VMFS device, it would map to the users directory of the account running the script. We used KB1033696 when we built the script as a guide and now the problem seems to be with "New-PSDrive -Name "mounteddatastore" -Root \ -PSProvider VimDatastore -Datastore (Get-Datastore "DatastoreName")"

##Sample Script##

New-PSDrive -Name "mounteddatastore" -Root \  -PSProvider VimDatastore -Datastore (Get-Datastore $datastore)

Set-Location "mounteddatastore"

##Folder triesto create on the local system where the script is running instead on the VMFS device##

New-Item -Path "Logs" -Name $ESXHOST -ItemType directory -Confirm:$false -Force:$true

SET-VMHostAdvancedConfiguration -VMHost $ESXHOST -Name "ScratchConfig.ConfiguredScratchLocation" -Value "/vmfs/volumes/$Datastore/Logs/$ESXHOST"

PowerCLI - 5.5 and 6.0

ESXi - 5.5u2 and 6.0u1

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

Did you already try by specifying the Path on New-Item as "mounteddatastore:/Logs" ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos