Powershell environment variables

broken image

So you can get that same variable this way: (Technically this is a different variable but I couldn’t figure out how to get the ProgramFiles(x86) to work. They appear to be stored in the registry but weren’t easy to find. Interestingly I did some research and I wasn’t able to find a list of this type of environment variable.

broken image

Some other ones I found include the path for the system and temp directories. This is handy because not every system uses C:\Program Files (x86) for that particular set of directories. For example %programfiles(x86)% that Kendra mentioned will tell you the location of the Program Files (x86) directory. So to start, in batch, cmdshell, or DOS (whatever you want to call it) you can use certain environment variables in your code. '%programfiles(x86)%Red GateSQL Compare 14SQLCompare.exe' /scripts1:'C:agent_work1State' /sca2:'C:agent_work1MigrationsDemoWorkflow_Migrations.sqlproj'

broken image

I tried to figure out the equivalent of this (which works in a cmd prompt) and… oy.

broken image