Hi there,
I am new to powershell but I can see how it can make life a lot easier.
I am trying to create a script that loops through each datacenter and exists whether a folder exists.
I haven't got very far as I am stuck early on :-)
I manage to get each folder fine and I stick the values in the $CurrentFolders array.
The array output looks as follows:
Name : Development
Name : UAT
I would like to check that $CurrentFolders contains a Production folder.
I have tried several ways but cannot extract values from my array.
/* Part of script ommited*/
#Loop through all datacenters and create top folders if not exist
ForEach ($DC in $DCs)
{
#Check whether top folders exists
write-host "hello $DC"
$CurrentFolders = @()
ForEach ($Folder in (Get-Folder -Location $DC | Select Name | Where-Object { "datacenters","datastore","host","vm","Templates" -notcontains $_.Name } ))
{
$CurrentFolders += $Folder
}
//Check for Production folder here
$Currentfolders
}
Any help appreciated :-)