Paramizi alan ve işlevleri kullanan bir powershell komut dosyası yazmak istiyorum. Params * ve * işlevlerine sahip Powershell komut dosyası
bu çalıştı:param
(
$arg
)
Func $arg;
function Func($arg)
{
Write-Output $arg;
}
ama bu var:
The term 'Func' is not recognized as the name
of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At func.ps1:6 char:5
+ Func <<<< $arg;
+ CategoryInfo : ObjectNotFound: (Func:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
İnce, diye düşündüm.
function Func($arg)
{
Write-Output $arg;
}
param
(
$arg
)
Func $arg;
Ama sonra, bu var: Bunun yerine bu çalışacağım
The term 'param' is not recognized as the name
of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At C:\Users\akina\Documents\Work\ADDC\func.ps1:7 char:10
+ param <<<<
+ CategoryInfo : ObjectNotFound: (param:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Ben yapılabilir için soruyorum var mı? Yoksa isteğimle mantıksız mıyım?
Bir powershell komut dosyasının sırası genellikle, 1) Params, 2) İşlevler 3) İşlev çağrıları/yürütme için cmdlet'ler. –
Christopher Ranney, bu yararlı bir özetleme. Bunu bir soru olarak göndermiş olsaydınız, onu oylardım. –
Kalbiniz çok arzulanırsa yorumları oylayabilirsiniz. :) –