I am trying to remove part of the text that is returned from get-wmiobject
, the text I am trying to remove is @{ShareName=PRT47}
and I only want the printer name that is returned so the suffix if you will.
I have tried different by attempting to get the number of characters and delete them but I have since found out that you can also use what is in the proceeding cmdlet.
$text = Get-WmiObject -Class $class -Filter Network=True | Select ShareName | Where-Object {$_ - like "*PRT*"}
ForEach ($shareName in $text) {
$newprinter = "\\$newserver\$shares"
rundll32 printui.dll,PrintUIEntry /in /n $newprinter
}