Hey all, i was hoping someone could explain some stuff to me. Now I’m no pro with powershell, but I really want to get better at it. And unfortunately I don’t really have a strong background in programming. So some of the way that programming stuff works doesnt really make sense.
Anyway, i was kind of thinking it’d be cool to do something on the lines of, install hyper-v, name computer, add to domain, and maybe add VMs to the host. But the scripts would need it to continue through reboot.
Thats where i found workflows So i figured id give it a try.
workflow hyperv{ param([String]$name) Sequence{ $name = 'Node5' Rename-computer -NewName $name -Force -Passthru Restart-Computer -Wait } }
I can get the first part to run ok and rename the computer, the adding to the domain part doesnt work so much. How would i go about doing that?
Also i had some random questions and im hoping that a better understanding of certain parts will make it all make more sense for me…
-
What is the point of adding the Param([String]) in there if i set the variable to something anyway? Is this field mainly for input?
-
I get that sequence does things in order, while parallel does stuff however, if i wanted to do more than one thing, like install hyper-v, restart, rename, restart, add to domain, restart… Would i need more than one Sequence block?
-
Same with the inline-script, what is the exact purpose of that besides executing single portions?
Anyway, thanks in advance for whoever reads this, hopefully most of it made sense.