我们正在创建PowerShell脚本以自动化Windows Server 2016中远程桌面服务环境的部署。我们想对PowerShell脚本进行参数化,但是这样做很麻烦。是通过Hiera还是通过模板或两者结合?
如果我们在PowerShell脚本中传递硬编码的变量值,则脚本会起作用,我们的目标是参数化脚本。
谢谢..所以我们有下面的脚本
Brokerwrapper.PS1
$domain = "abc.com"
$password = "somepassword" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\user1"
$credential = New-Object
System.Management.Automation.PSCredential($username,$password)
echo "Starting Brokerwrapper.PS1" >> c:\rdssetup.txt
start-process powershell.exe -credential $credential -argumentlist "start-
process powershell -argumentlist C:\puppet\Setup-Broker.PS1 -verb runas"
echo "Finishing Brokerwrapper.PS1" >> c:\rdssetup.txt
Setup-Broker.PS1
$domain = "abc.com"
New-RDSessionDeployment -ConnectionBroker "brokervm.abc.com" -SessionHost "sessionhost.abc.com"
现在我们要参数化域,用户等