2016-04-03 26 views
0

Benim powershell komut Bu benim ilk powershell komutPowershell acemi

olduğunu

Unexpected token 'Function' in expression or statement. 
    + CategoryInfo   : ParserError: (:) [], ParseException 
    + FullyQualifiedErrorId : UnexpectedToken 

o

[CmdletBinding()]param() 
process{ 
# call function a 
# call function b 
} 
end{} 
Function a{ 
[CmdletBinding()]param() 
process{} 
} 
Function b{ 
[CmdletBinding()]param() 
process{} 
} 

yukarıdaki yapı bildiren bir hata atar aşağıdaki yapıya sahiptir

Herhangi bir yardım samimiyetle takdir ediyor

Teşekkürler

+1

uygulamak zaman ' Begin-Process-End 'bir fonksiyonda, dışarıdan kod koyamazsınız * Bu üç bloktan. İç fonksiyonlarınızı 'begin' bloğuna yerleştirin –

cevap

1

End Bölüm içeride Process Bölüm içeride

Temizleme kodunuzu Yürütme begin veya Process Bölüm içeride Fonksiyonlarınızı beyan

Örnekler bakınız:

[CmdletBinding()]param() ## BTW: You don't need this line if you are not using args 

begin{ 

"Declare Functions in begin`n" 
Function Get-Number{ 
"Number: " + (Get-Random) 
} 

Function Get-Time{ 
Get-Date 
} 

} 

process{ 

"Execute Function in process" 
Get-Number 
Get-Time 

} 
end{ 
"`nEnd of code" 
}