Gather User Account Name during IPU

This came about because we wanted to confirm the user account that initiated the upgrade in software center.  This script will then capture that information into a TS Variable, and can then be written to Registry / WMI using our collect information script that runs.  Both the Script and the Step in the TS have conditions on them, where it looks for _SMSTSUserStarted to be “True”

Note, this is for the interactive console user, if you have VM’s they users RDP into, you’d have to change the “Type” from 2 .. to I think 10.  More info about this process on the page where I stole most of the code from: https://gallery.technet.microsoft.com/scriptcenter/0e43993a-895a-4afe-a2b2-045a5146048a

image

image

Code: Set-IPU_UserAccountTSVar.ps1

Then in conjunction with the Set Info Script, it will record to registry / WMI
POST HERE: https://garytown.com/collect-osd-ipu-info-with-hardware-inventory

image

image

1 thought on “Gather User Account Name during IPU”

  1. I was coming over to garytown to take a peak at your post on getting rid of MDT and saw this. Interesting that I was trying to figure out this same thing a few weeks ago and found a different solution. I deconstructed the PSADT and used their code to do the same thing. Your code above returns multiple users if anything is launched and running with a 'Run As' in my quick testing. In using the PSADT, they get a nice usable object. I've been having good success with this..

    $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
    [string[]]$ReferencedAssemblies = 'System.Drawing', 'System.Windows.Forms', 'System.DirectoryServices'
    Add-Type -Path "$scriptPath\AppDeployToolkitMain.cs" -ReferencedAssemblies $ReferencedAssemblies
    $user=[PSADT.QueryUser]::GetUserSessionInfo("$env:ComputerName")
    try{
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
    $tsenv.Value("ConsoleUser") = "$($user.UserName)"
    }
    catch{
    Write-host "Not running a TS. Would set variable [ConsoleUser] to [$($User.UserName)]"
    }

    AppDeployToolkitMain.cs is found in the toolkit.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.