


(New-Object -ComObject WScript.Network).RemovePrinterConnection("\\APP01\Safecom_Black") (New-Object -ComObject WScript.Network).SetDefaultPrinter('\\APP01\SafeQ-BW') Powershell.exe -executionpolicy bypass -file "\NO.SCR\Add-And-Remove-Printers.ps1"Īdd-printer -ConnectionName "\\APP01\SafeQ-Color"Īdd-printer -ConnectionName "\\APP01\SafeQ-BW" I hope someone can help me with this one. All my other PS scripts works, so maybe there is something that I have overlooked? I want to delete some of the printers that the users have, and add some new + setting it as default. It works perfectly when I run it locally on my machine, but when I deploy it, it does not work. It needs more time to execute but I think you have all the information you need.Hi! I have some issues when deploying my PowerShell script. $Report | Export-csv C:\Temp\Tasks_"$Date"_"$Time".csv -NoTypeInformation $Details.LastTaskResult = $Info.LastTaskResult $Details = "" | select ComputerName, Task, User, Enabled, Application, LastRunTime, LastTaskResult

$Info = Get-ScheduledTask -CimSession $Computer -TaskName $task | Get-ScheduledTaskInfo | Select LastRunTime, LastTaskResult $tasks = Get-ChildItem -recurse -Path $path -File If (test-connection $Computer -quiet -count 1) $Computers >C:\Temp\servers_"$Date"_"$Time".txt $Computers = (get-adcomputer -filter ).name The modification helps find tasks in nested folders and lists the status of the task as well as details included in the original. Hey thought I'd share a modified version of the script posted by Ob1lan.

> SRV021,Compress&Archive,DOMAIN\sysScheduler > SRV021,BackupMailboxes,DOMAIN\administrator > SRV030,GoogleUpdateTaskMachineUA,System > SRV029,GoogleUpdateTaskMachineCore,System The output is a comma-separated file generated on your desktop, like this one : > SRV028,CCleanerSkipUAC,administrator Write-Verbose -Message "Writing the log file with values for $computername"Īdd-content -path $logfilepath -Value "$computername,$item,$check" Write-Verbose -Message "I found $($unt) tasks for $computername" $path = "\\" + $computername + "\c$\Windows\System32\Tasks" $ErrorActionPreference = "Silentl圜ontinue" $logfilepath = "$home\Desktop\TasksLog.csv" Write-Verbose -Message "Trying to query $($unt) servers found in AD" $list = (Get-ADComputer -LDAPFilter "(&(objectcategory=computer)(OperatingSystem=*server*))").Name Not yet perfect but totally working to list all tasks of all servers, and log which user account is used to run them. Then it will write the value of the UserID xml node of each file, in the final CSV file. This script will 'scan' all the servers listed in AD, searching in the c:\Windows\System32\tasks folder for xml files. I finally wrote a script that suits my needs.
