Hey all was testing an idea with a script to help some of my student assistants with our Windows 10 roll out - so I'm making a restore script to compliment a backup one I made a while ago. It saves .csv's files on a public file share. I was attempting to reinstall all the network printers a user has on a .csv file by invoking rundll32 - it sees my list of printers and shows a installing printers window that stops shortly after that. None of the printers get added and its got me quite stumped. Seems like an easy enough process and could use some outside eyes with why this isnt working.
Thanks all!
$PrinterNames = Get-WmiObject -class win32_printer -ComputerName $env:COMPUTERNAME | where{$_.name -like '\\ps01*'} | select Name | Export-Csv -path C:\users\jheathe2\documents\Printer_export.csv
$GetPrinter = Import-Csv -LiteralPath C:\users\jheathe2\documents\Printer_export.csv
ForEach ($Printer in ($GetPrinter | %{$_.Name -like "\*"}))
{Invoke-Expression 'rundll32 printui.dll PrintUIEntry /in /q /n $($GetPrinter.name)'}
I excluded the pull from the fileshare part as my example because I wanted to know why rundll32 wasn't working more, as that's the barrier I am working with currently.