Virtually anything can be done using PowerShell, if you have the proper time to understand the requirements, what you want to achieve and build the script. Whenever I have the opportunity I like to automate some tasks, basically to save some time and let me work on different things.
I had this script for a while, to easily configure VMware Dynamic Environment Manager during deployments and doing Lab, saving some time which could be spent on tougher and not time-consuming tasks.
I have only put together in a proper format adding some quick features to prompt the requirements.
So just run it and enjoy. 😉
Don’t forget to run the script as Administrator, it can be used in any SMB/CIFS/NFS solution, which your running account has administrative privileges.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
<# .SYNOPSIS VMware DEM Shared Folders Setup .DESCRIPTION Automatically create Shared Folders for VMware Dynamic Environment Manager setup with proper permissions by VMware Docs .INSTRUCTIONS Run the Script as Administrator (Required to configure Windows Shares) Enter the proper values as the examples .AUTHOR Rafael Moura @ VirtuallyAnything.net - Jun/2021 .VERSION 1.0 #> #.#.# Variables #.#.# Write-Host "Setting Variables" -ForegroundColor Cyan #.DEM Config Share #. Write-Host "DEM Config Folder Settings" -ForegroundColor Yellow #.Folder Path $DEMConfFo = Read-Host -Prompt 'Enter the DEM Config Folder Path (i.e. D:\Shares\DEMConfig)' #.Share Name $DEMConfSh = Read-Host -Prompt 'Enter the DEM Config Share Name (i.e. DEMConfig$)' #. #.DEM Profile Share #. Write-Host "DEM Profile Folder Settings" -ForegroundColor Yellow #.Folder Path $DEMProfFo = Read-Host -Prompt 'Enter the DEM Profile Folder Path (i.e. D:\Shares\DEMProfile)' #.Share Name $DEMProfSh = Read-Host -Prompt 'Enter the DEM Profile Share Name (i.e. DEMProfile$)' #. #.DEM Groups: #. Write-Host "DEM Permissions Settings" -ForegroundColor Yellow #.DEM Administrators Group $DEMAdm = Read-Host -Prompt 'Enter the DEM Admin Group (i.e. Domain\Horizon Admins)' #.DEM Users Group $DEMUsr = Read-Host -Prompt 'Enter the DEM Users Group (i.e. Domain\Horizon Users)' #.-----------------------------------------------------------------.# #. Don't change any value below .# #.-----------------------------------------------------------------.# #. Write-Host "::: Action Phase :::" -ForegroundColor Green Write-Host "Getting Permissions" -ForegroundColor Green #.VMware DEM Permissions $PConf = ":(OI)(CI)RX" $PFull = ":(OI)(CI)F" $PProf = ":(NP)(AD)" $POwn = "CREATOR OWNER:(OI)(CI)F" #.ICACLS Variables $ReplIn = "/inheritance:r" $Grt = "/grant" $RemAdm = "Administrators" $Rem = "/remove" Write-Host "Creating DEM Config Folder" -ForegroundColor Green #.VMware DEM Config Share md $DEMConfFo Write-Host "Configuring DEM Config Permissions" -ForegroundColor Green net share $DEMConfSh=$DEMConfFo /GRANT:Everyone,CHANGE Invoke-Expression -Command ('icacls $DEMConfFo $ReplIn') Invoke-Expression -Command ('icacls $DEMConfFo $Grt "${DEMUsr}${PConf}"') Invoke-Expression -Command ('icacls $DEMConfFo $Grt "${DEMAdm}${PFull}"') Invoke-Expression -Command ('icacls $DEMConfFo $Rem $RemAdm') Write-Host "Creating DEM Profile Folder" -ForegroundColor Green #.VMware DEM Profile Share md $DEMProfFo Write-Host "Configuring DEM Profile Permissions" -ForegroundColor Green net share $DEMProfSh=$DEMProfFo /GRANT:Everyone,CHANGE Invoke-Expression -Command ('icacls $DEMProfFo $ReplIn') Invoke-Expression -Command ('icacls $DEMProfFo $Grt "${DEMUsr}${PProf}"') Invoke-Expression -Command ('icacls $DEMProfFo $Grt "${DEMAdm}${PFull}"') Invoke-Expression -Command ('icacls $DEMProfFo $Grt $POwn') Invoke-Expression -Command ('icacls $DEMProfFo $Rem $RemAdm') |