SOLVED
Home

Creating a pool and hosts via Powershell

%3CLINGO-SUB%20id%3D%22lingo-sub-799621%22%20slang%3D%22en-US%22%3ECreating%20a%20pool%20and%20hosts%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-799621%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20working%20on%20a%20script%20to%20try%20and%20create%20a%20new%20pool%2C%20a%20number%20of%20hosts%2C%20grant%20permissions%20to%20them%20and%20then%20join%20the%20hosts%20to%20the%20pool.%20This%20all%20looks%20fairly%20doable%20but%20the%20only%20bit%20that%20looks%20a%20little%20tricky%20to%20automate%20is%20joining%20the%20created%20hosts%20to%20the%20pool.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELooking%20over%20the%20WVD%20documentation%20I%20need%20to%20generate%20a%20token%20for%20the%20RDS%20pool%2C%20then%20install%20the%20agent%20on%20each%20host%20and%20enter%20the%20token.%20Is%20there%20a%20way%20to%20silently%20do%20this%20via%20the%20agent%20installer%2C%20or%20some%20other%20method%20I've%20not%20discovered%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EObviously%20I%20can%20create%20the%20pool%20and%20hosts%20directly%20in%20Azure%20which%20achieves%20this%2C%20but%20I'd%20prefer%20to%20automate%20this%20in%20Powershell%20instead%20though.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-799621%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Erdsh%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWVD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-800560%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20pool%20and%20hosts%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-800560%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F390754%22%20target%3D%22_blank%22%3E%40OmegaHarvest%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20it%20can%20help%2C%20I%20use%20this%20small%20script%20after%20creating%20my%20machine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24msiwvd%20%3D%20%22wvd.msi%22%0A%24agentloaderWVD%20%3D%20%22wvdbootloader.msi%22%0A%0A%24RegistrationToken%20%3D%20%22%3CYOUR%20token%3D%22%22%3E%22%0A%0Acurl%20-o%20%24msiwvd%20%3CA%20href%3D%22https%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrmXv%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrmXv%3C%2FA%3E%0Acurl%20-o%20%24agentloaderWVD%20%3CA%20href%3D%22https%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrxrH%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrxrH%3C%2FA%3E%0A%0A%23%20Install%20agent%20loader%0AStart-Process%20-FilePath%20%22msiexec.exe%22%20-ArgumentList%20%22%2Fi%20%24agentloaderWVD%22%2C%20%22%2Fquiet%22%2C%20%22%2Fqn%22%2C%20%22%2Fnorestart%22%2C%20%22%2Fpassive%22%2C%20%22%2Fl*%20C%3A%5CUsers%5CAgentBootLoaderInstall.txt%22%20-Wait%20-Passthru%0A%0A%24agent_deploy_status%20%3D%20Start-Process%20-FilePath%20%22msiexec.exe%22%20-ArgumentList%20%22%2Fi%20%24msiwvd%22%2C%20%22%2Fquiet%22%2C%20%22%2Fqn%22%2C%20%22%2Fnorestart%22%2C%20%22%2Fpassive%22%2C%20%22REGISTRATIONTOKEN%3D%24RegistrationToken%22%2C%20%22%2Fl*%20C%3A%5CUsers%5CAgentInstall.txt%22%20-Wait%20-Passthru%0A%24sts%20%3D%20%24agent_deploy_status.ExitCode%0AWrite-Output%20%22Installing%20RD%20Infra%20Agent%20on%20VM%20Complete.%20Exit%20code%3D%24sts%60n%22%0A%0AStart-Service%20RDAgentBootLoader%3C%2FYOUR%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-800797%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20pool%20and%20hosts%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-800797%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F390754%22%20target%3D%22_blank%22%3E%40OmegaHarvest%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20it%20can%20help%20you%20I%20use%20the%20following%20code%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24msiwvd%20%3D%20%22wvd.msi%22%0A%24agentloaderWVD%20%3D%20%22wvdbootloader.msi%22%0A%24RegistrationToken%20%3D%20%22%22%0A%0A%0Acurl%20-o%20%24msiwvd%20%3CA%20href%3D%22https%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrmXv%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrmXv%3C%2FA%3E%20%0Acurl%20-o%20%24agentloaderWVD%20%3CA%20href%3D%22https%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrxrH%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fquery.prod.cms.rt.microsoft.com%2Fcms%2Fapi%2Fam%2Fbinary%2FRWrxrH%3C%2FA%3E%0A%20%0A%23%20Install%20agent%20loader%0AStart-Process%20-FilePath%20%22msiexec.exe%22%20-ArgumentList%20%22%2Fi%20%24agentloaderWVD%22%2C%20%22%2Fquiet%22%2C%20%22%2Fqn%22%2C%20%22%2Fnorestart%22%2C%20%22%2Fpassive%22%2C%20%22%2Fl*%20C%3A%5CUsers%5CAgentBootLoaderInstall.txt%22%20-Wait%20-Passthru%0A%0A%24agent_deploy_status%20%3D%20Start-Process%20-FilePath%20%22msiexec.exe%22%20-ArgumentList%20%22%2Fi%20%24msiwvd%22%2C%20%22%2Fquiet%22%2C%20%22%2Fqn%22%2C%20%22%2Fnorestart%22%2C%20%22%2Fpassive%22%2C%20%22REGISTRATIONTOKEN%3D%24RegistrationToken%22%2C%20%22%2Fl*%20C%3A%5CUsers%5CAgentInstall.txt%22%20-Wait%20-Passthru%0A%24sts%20%3D%20%24agent_deploy_status.ExitCode%0AWrite-Output%20%22Installing%20RD%20Infra%20Agent%20on%20VM%20Complete.%20Exit%20code%3D%24sts%60n%22%0A%0AStart-Service%20RDAgentBootLoader%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-803186%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20pool%20and%20hosts%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-803186%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F390754%22%20target%3D%22_blank%22%3E%40OmegaHarvest%3C%2FA%3E%26nbsp%3B%3A%20Have%20you%20taken%20a%20look%20at%20the%20GitHub%20ARM%20template%20we%20have%20that%20helps%20you%20create%20VMs%20then%20register%20them%20to%20a%20host%20pool%3F%20You%20should%20be%20able%20to%20extract%2Fre-use%20a%20lot%20of%20the%20PowerShell%2FPowerShell%20DSC%20logic%20from%20it%20if%20the%20tool%20doesn't%20match%20your%20needs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FRDS-Templates%2Ftree%2Fmaster%2Fwvd-templates%2FCreate%2520and%2520provision%2520WVD%2520host%2520pool%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2FRDS-Templates%2Ftree%2Fmaster%2Fwvd-templates%2FCreate%2520and%2520provision%2520WVD%2520host%2520pool%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-804566%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20pool%20and%20hosts%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-804566%22%20slang%3D%22en-US%22%3EThis%20looks%20helpful%2C%20thanks.%3C%2FLINGO-BODY%3E
Deleted
Not applicable

I'm working on a script to try and create a new pool, a number of hosts, grant permissions to them and then join the hosts to the pool. This all looks fairly doable but the only bit that looks a little tricky to automate is joining the created hosts to the pool.

 

Looking over the WVD documentation I need to generate a token for the RDS pool, then install the agent on each host and enter the token. Is there a way to silently do this via the agent installer, or some other method I've not discovered?

 

Obviously I can create the pool and hosts directly in Azure which achieves this, but I'd prefer to automate this in Powershell instead though.

2 Replies
Solution

@Deleted : Have you taken a look at the GitHub ARM template we have that helps you create VMs then register them to a host pool? You should be able to extract/re-use a lot of the PowerShell/PowerShell DSC logic from it if the tool doesn't match your needs.

 

https://github.com/Azure/RDS-Templates/tree/master/wvd-templates/Create%20and%20provision%20WVD%20host%20pool

This looks helpful, thanks.
Related Conversations
Extentions Synchronization
Deleted in Discussions on
3 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
36 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
9 Replies