Skip to content

Instantly share code, notes, and snippets.

@FlintSable
Last active August 3, 2022 20:17
Show Gist options
  • Select an option

  • Save FlintSable/ea43716ceac94228fada583a0ae73b79 to your computer and use it in GitHub Desktop.

Select an option

Save FlintSable/ea43716ceac94228fada583a0ae73b79 to your computer and use it in GitHub Desktop.
Powershell
# Logger function usage
# Create a folder in this directory \\sccm\sccm$\UpgradeLog
# call the function like this
# logger "string to log"
function logger{
param(
[string]$arg0
)
# define these values
$path_to_log_folder = "\\scc\scc$\UpgradeLog"
$name_of_folder = "TesterLog"
$CPName = $Env:COMPUTERNAME
$Username = (Get-WmiObject -Class Win32_ComputerSystem | select username).Username.Substring(5)
$Username = (Get-Culture).TextInfo.ToTitleCase($Username)
function Time {
$d = Get-Date
[string]$dw = $d.DayOfWeek
$dw = $dw.Substring(0,3)
$dw + " " + $d
}
Add-Content $path_to_log_folder\$name_of_folder\$CPName-$Username.txt "$(time) $CPName $Username $arg0"
}
logger "test call this wherever you need test 1"
logger "test call this wherever you need test 2"
logger "test call this wherever you need test 3"
logger "test call this wherever you need test 4"
logger "test call this wherever you need test 5"
logger "test call this wherever you need test 6"
logger "test call this wherever you need test 7"
logger "test Close out log test 8"
logger "---------------------------------------"
psExec \\\\WS886 cmd
psExec \\WS886 cmd
psExec '\\WS886' cmd
https://community.spiceworks.com/how_to/78664-remove-local-printer-on-a-remote-machine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment