A newbie mistake with PowerShell

At work, I wrote a PowerShell script to automate our build process. I had to use the Visual SourceSafe command line tool to check out the files, make changes, and check them back in. The SS tool expected the ssdir environment variable to be set properly. I had just begun using PowerShell and I made the foolish mistake of assuming that the Set-Variable command could set environment variables. It took me a few minutes to realize this folly 😳

For other PowerShell newbies, the following snippet should make things clear :-

Set-Variable ssdir \\somemachine\vss
((Get-Variable ssdir).Value -eq $env:ssdir)

The output of line 3 will be False.


2 thoughts on “A newbie mistake with PowerShell

  1. We are not using NAnt, but the script does use MSBuild internally. The script does a lot of stuff other than building – like modifying certain file headers, directly editing an old VB6 project file, copying release and pdbs to a network share, uploading symbols to a symbol server etc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s