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]]]]]]]]
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