I am working with appsense getting location based printing working. Short of it is I am setting environment variables that say where an endpoint is. where I am stuck is setting the dfault printer
basically I am adding printers by environment variables we are setting in appsense.
so ENVVARIABLE1=\printerserver\printer1
ENVVARIABLE2 = \printerserver\printer2
ENVVARIABLE3 = \printersernver\printer3
I have the commands working to add the printers and I can see it calling it by the printer sharename when I try to pull it for the default printer. But I get a null-value when it try to do the default printer on ENVVARIABLE1. It first states
Get-WMIObject : Invalid query"select * from Win32Printer where Name='\Printserver\Printer1"
this tells me Its seeing the env variable but I get a null value when I try and $default into the default printe rcommnad.
I will try the Select-Object option and see if I can get that to work
What Curtis said. This was the exact thought I had when I read the thread title. You’d likely be better suited to use GPP for this task. I love PowerShell, but there’s times when it’s not the solution.
I also noticed that you have single quotes around the $default variable when trying to set the default printer. Powershell interprets text in single quotes as literal so perhaps you may just need to escape the single quotes with a backtick to get your current code to work. Bear in mind that I’m answering on mobile with no chance to test my suggestion.
@Peter: Because the single-quotes are inside of double-quotes, the single-quotes will be interpreted as text and not interfere with the variable expansion.
@Michael: I don’t know if you typed this out as an example of your script, but it is full of typos from what I can tell.
You are setting $Printer1 three times in a row to the same thing, and then later you are calling $Prnter1 and $Prnter2, etc. Notice that the variable you use later is missing the “i” in the word “Printer”? Also, you misspelled “default”, you misspelled “network” and some other things.
I’m assuming you must have just typed this out on the fly here or something. If that’s the case, try posting your verbatim code so we can try to help you pinpoint the problem.
@ Curtis Smith & Tommy Maynard We are using appsnese and the client has old 2003 architecture for with a ton of AD sync and GPO issues. the building is 7 floors with about 200 printers and the easiest way was to leverage appsense to set env variables buy printer and endpoint name. Alot of the endpoints are linux based for VDI which makes it hard to keep it uniform with two different solutions. So I was searching for a powershell solution to run in appsense. Trust me that was suggested.
@ Peter and Jessi sorry for the typos and thanks for the input
To all I figured out that the command to set the printer to default was looking for the share name. I was able to figure out the command which i will post tomorrow with a better explanation.
Sorry I have to retype things and make sure you cannot see certain information like computer names and IP information.