FlintSable
6/20/2017 - 10:02 PM

Powershell

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