Reputation: 3
Someone can tell me if is possible pass variables when i call Remove-Printer command on Powershell?
Remove-Printer -Name 'Printer1 (Copy $i)'
Idk if this is possible but i tried this:
for ($i=0; $i -le 5; $i ++) {
Remove-Printer -Name 'Printer1 (Copy '+$i+')'
}
and more unsuccessful attempts...
If someone can help me... thanks you.
Upvotes: 0
Views: 202
Reputation: 2281
The single quotes tells PowerShell that there are character literals inside. Just use double quotes, and $i had a space after it (the $i++ part) in the for loop constructor.
for ($i=0; $i -le 5; $i++) {
Remove-Printer -Name "Printer1 (Copy $i)"
}
Upvotes: 1