Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

$Env line of code failing

$
0
0
I have this code that is supposed to add collections to SCCM 2007. I load this up in PowerGUI and it displays a 'red error line' under the the double quote after computername. On this line: $Computer = "$env:computername", It throws up this error: Unexpected token 'env:computername' in expression or statement.

My question is why? What is wrong with the syntax on this one line of code? 



$Site_Prefix = "AB1 - SCCMCEN01, Central Site 1 (San Francisco))" 
$CollectionNames = @("Albuquerque","Anchorage) 

# Create Collection function 
Function Create-Collection 

Param( 
$Computer = "$env:computername",     <<<< Error on this line <<<<
$SiteCode, 
$CollectionName, 
$ParenCollectionID



$CollectionClass = "SMS_Collection" # WMI Class 
$SubCollectionClass = "SMS_CollectToSubCollect" # WMI Class 
$Colon = ":" 
$FullSiteName = "Site_$SiteCode" 


$WMIConnection = [WmiClass]]]]]]]] 

mqh7


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>