I just want to make sure that I understand this correctly and am not missing anything.
<span style=“font-size: 13px;”>
[string]$computername = ‘localhost’
$a = get-WmiObject -Class win32_operatingsystem -ComputerName $computername
$b = Get-WmiObject -Class win32_computersystem -ComputerName $computername
Obviously the above code is not complete. Â Once complete I could run the script and pass in the computername parameter and have it run against remote computers. Â Is it correct that I can only pass the computername parameter into this script because the commands the script utilizes depend on the -computername parameter?
For example, this would not work:
param( [string]$computername = 'localhost' ) $a = set-itemproperty -path c:\GroupFiles\final.doc -name IsReadOnly -value $true Â -ComputerName $computername $b = New-Item c:\hello -ComputerName $computername
If I ran the above ./script1.ps1 -computername win8 , it would not work because the commands in the script do not accept the -computername parameter. Â Is that right?