I’ve been investigating Windows PowerShell today, and it struck me that it might have the potential to be a pretty useful tool to add to the arsenal…
We’re a pretty C# heavy studio, using it for the vast majority of our tools and pipelines, and PowerShell’s interoperability with .Net seems intriguing. I was curious if anyone else had any experience with PowerShell and might share some of their findings??
Thanks in advance!
edit: here’s a video with some of the capabilities…
I was just wondering if there was anyone out there using PowerShell and thought I’d do a search.
I’ve been using it extensively for automation and tools specifically because cmd.exe is kind ancient and our game engine is all .net. I’ve been loving it.
We settled on scripting host here. Downside for powershell - it’s an optional install for XP which just doesn’t work for us because artists need admin rights to install it and for that we have to call IT. Powershell is supposedly the successor for scripting host so it’s probably a great tool.
At least it beats writing batch scripts and it offers standard string and file manipulation commands. That alone is just awesome
I’ve read many blog posts about it and it seems pretty nifty. However I’d consider something like python/IronPython a more likely candidate for things we need to do in the TA role- I’m loathe to introduce yet more languages by choice, especially one outside of our traditional domain.
We usually use this for tool deployment to artist machines as a super fail-safe method.
It would be awesome if we could use Python, but there’s some downsides to Python.
The correct python version needs to be installed on the target machine, and then it should be in the system path. If we want to query the x64 registry from python (e.g. to find out if Maya x64 is installed) then we actually need to launch the script from a x64 python installation. However some people have x86 python installed on x64 machines, or there are multiple Python installations on the machine… at this point things just get really complicated (at least more complicated than you want when just writing a simple tool deployment script!).
Compiling Python scripts with py2exe isn’t an option either since we still need separate x64 and x86 binaries. Also we rob ourselves of the ability to quickly change scripts on the go if needed.
I have to say we’re an outsourcer and the specs of our workstations vary WIDELY because some client’s tools require/only-work-with XP, Win7,x64,x86,etc. Some of our client’s tools have the bad habit of modifying the systems pretty heavily. So we always have to assume the worst when we deploy anything…
I haven’t tried powershell because we want something that ships with every windows version from XP up, but scripting host can be scripted in Visual Basic or Javascript. TAs pick up Javascript pretty quickly - even more so if they happened to work with Web apps or Unity before.
Right now we code the installation scripts in javascript. We copy files, query the registry, read .ini files, even create custom maya shelves all in javascript. Only UIs we do in Python because it’s easier for the TAs to code them there. Since the UI doesn’t do much it’s safe to just compile it with py2exe (so we don’t depend on an installed python interpreter) and call it from the javascript.
Finally the decision of what to use goes like this: we use scripting host where we would have used batch files in the past. We use scripting host if we cannot guarantee that python is installed on a machine. We use scripting host if we want the script to be x64 aware and capable of accessing win x64 specifics. Everything else -> python.
That’s not true. You can query either 32 or 64 bit registry hives from either 32 or 64 bit Python. You just have to explicitly specify one of these redirection flags:
KEY_WOW64_64KEY
KEY_WOW64_32KEY
Without that it will assume you want the hive that matches the architecture of the requesting program. See this MSDN page for more details.
Regarding Powershell, I’ve liked what I’ve seen and been meaning to use it more.
We switch to the x86 hive and query the values we need, then we switch to the x64 hive and query the values we need, just as described. But when launched as 32 bit app the switching didn’t accomplish anything. In this case we got the x86 values twice. We had this issue in Python and later in scripting host (when launching via 32 bit cscript.exe on a 64 bit system). So it only worked when launched from x64.
Since we didn’t get any error messages and ran out of time we finally gave up on it
We solved the problem going to scripting host (not just because of that, but it was a factor in the decision). It always executes in the bit depth matching your system.
Maybe there’s something wrong with our call to switch the hive, but it does work on x64… I have to admit I ran out of knowledge here.
Edit: also the registry is locked by IT on our system, so it just allows read-only access. Maybe that has something to do with it…