I have created a function called Uninstall-Software. I created 2 param at the top
functionUninstall-Software
{
param
(
[string]
$ComputerName='',
[string]
$Remove=""
)
This is followed by code. From the bottom of my PowerShell ISE window, at the PS C:\> prompt I can type inget-helpUninstall-Software. It returns the following.
NAME
Uninstall-Software
SYNTAX
Uninstall-Software [[-ComputerName] <string>] [[-Remove] <string>]
ALIASES
None
REMARKS
None
From the bottom of my PowerShell ISE window, at the PS C:\> prompt I can type inUninstall-Software-C (it will autofill in ComputerName) -R (it will autofull in Remove)
But when I try to call this function with this command I get the error below.
$pc=Read-Host"Enter remote computer name"
$remove1=Read-Host"Enter software to uninstall"
Invoke-Command-FilePath"\\server1\PSScripts\UninstallSoftware.ps1"-ComputerName$pc-Remove$remove1
PS C:\> C:\Dropbox\Scripts\PowerShell\Functions\Call Uninstall Software Function.ps1
Enter remote computer name: cclab3
Enter software to uninstall: snagit
Invoke-Command : A parameter cannot be found that matches parameter name 'Remove'.
At C:\Dropbox\Scripts\PowerShell\Functions\Call Uninstall Software Function.ps1:7 char:94
+ ... 01\PSScripts\UninstallSoftware.ps1" -ComputerName$pc-Remove$remove ...
why?
functionUninstall-Software
{
param
(
[string]
$ComputerName='',
[string]
$Remove=""
)
This is followed by code. From the bottom of my PowerShell ISE window, at the PS C:\> prompt I can type inget-helpUninstall-Software. It returns the following.
NAME
Uninstall-Software
SYNTAX
Uninstall-Software [[-ComputerName] <string>] [[-Remove] <string>]
ALIASES
None
REMARKS
None
From the bottom of my PowerShell ISE window, at the PS C:\> prompt I can type inUninstall-Software-C (it will autofill in ComputerName) -R (it will autofull in Remove)
But when I try to call this function with this command I get the error below.
$pc=Read-Host"Enter remote computer name"
$remove1=Read-Host"Enter software to uninstall"
Invoke-Command-FilePath"\\server1\PSScripts\UninstallSoftware.ps1"-ComputerName$pc-Remove$remove1
PS C:\> C:\Dropbox\Scripts\PowerShell\Functions\Call Uninstall Software Function.ps1
Enter remote computer name: cclab3
Enter software to uninstall: snagit
Invoke-Command : A parameter cannot be found that matches parameter name 'Remove'.
At C:\Dropbox\Scripts\PowerShell\Functions\Call Uninstall Software Function.ps1:7 char:94
+ ... 01\PSScripts\UninstallSoftware.ps1" -ComputerName$pc-Remove$remove ...
why?