So,
i’ve tried to learn it already two days and unfotinatly, i’m not getting something write
i watched lots of videos and read lots of articales and still don’t get it
so i need your help
i’ve tried two difreint scripts through the “function” parameter
first is a very very basic and the second one is abit less basic and i dont’ understand what is the problem
script which is worked:
function my-test {
param($test)
write-host "i did a $test"
}
second script which is not working:
function net-test {
$levspc = "computername"
Read-Host "what is the computer name?"
param (Test-Connection -computername $levspc -Count 1)
write-host "the $levspc is alive "
}
That is not a parameter definition. That is executable code. A parameter is a “placeholder” (a variable, really) for a piece of information that you want input into your script or function. That’s not what you’ve done here. Aside from a ValidationScript(), which is a bit of a more advanced topic, parameter blocks aren’t executable code. They’re definitions, or declarations, of inputs that the script or function can accept.
We don’t support private messaging on the site; it’s been a problem in the past what with spammers and all. And, because of my job, I’m not allowed to provide private consulting or assistance, so it’s easier to have that turned off for me.
Sure, but Google hits our site almost constantly, so I can’t guarantee that a post will be deleted before they cache it. You can also use the “HMU” menu item on DonJones.com, if you need to send something that you don’t want to be public, provided it isn’t a technical assistance issue.