Powershell Version of CMD SET

Posted by Isaac Blum at 18 February 2010

Category: Business, For The Greater Good, Free Help, PowerShell

Thank you wes

If you are like me and are just so used to typing set to list and set environment variables then you might find this script useful.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if (test-path alias:set) { remove-item alias:set > $null }
function set
{
	[string]$var = $args
	if ($var -eq "")
	{
		get-childitem env: | sort-object name
	}
	else
	{
		if ($var -match "^(\S*?)\s*=\s*(.*)$")
		{
			set-item -force -path "env:$($matches[1])" -value $matches[2];		
		}
		else
		{
			write-error "ERROR Usage: VAR=VALUE"
		}
	}	
}
  • Share/Bookmark

Leave a Reply

Leave a Reply
  • (required)
  • (required) (will not be published)

  • Archives

  • Pages

  • Tags

  • More

Get Adobe Flash playerPlugin by wpburn.com wordpress themes