Set-Folder
VMware: Modifies the properties of a folder
#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$VIServer,
[Parameter(Mandatory = $true)]
[pscredential]$VICredential,
[Parameter(Mandatory = $true)]
[string]$FolderName,
[Parameter(Mandatory = $true)]
[string]$NewName
)
Process {
try {
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$folder = Get-Folder -Server $vmServer -Name $FolderName -ErrorAction Stop
if ($null -eq $folder) { throw "Folder $FolderName not found" }
$result = Set-Folder -Server $vmServer -Folder $folder -Name $NewName -Confirm:$false -ErrorAction Stop | Select-Object *
if ($null -ne $result) { $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force }
}
catch { throw }
finally { if ($null -ne $vmServer) { Disconnect-VIServer -Server $vmServer -Force -Confirm:$false -ErrorAction SilentlyContinue } }
}IP address or DNS name of the vSphere server
PSCredential object for authenticating with the server
Folder whose properties to change
New name for the folder