I want to use this custom function in PSATD :slight_smile: Can you help me ?

Function CurrentUser {
$LoggedInUser = get-wmiobject win32_computersystem | Select-Object username
$LoggedInUser = [string]$LoggedInUser
$LoggedInUser = $LoggedInUser.split(β€œ=”)
$LoggedInUser = $LoggedInUser[1]
$LoggedInUser = $LoggedInUser.split(β€œ}”)
$LoggedInUser = $LoggedInUser[0]
$LoggedInUser = $LoggedInUser.split("")
$LoggedInUser = $LoggedInUser[1]
Return $LoggedInUser

$user = CurrentUser

#Select-String -Path β€œC:\Local\igg.txt” -Pattern β€œ$user” -Quiet
if(Select-String -Path β€œC:\Local\igg.txt” -Pattern β€œ$user” -Quiet) {write-host β€œyes”} Else {write-host β€œNo”}

Read this:
Functions - PowerShell | Microsoft Learn
or this:
Mastering PowerShell Functions: A Step-by-Step Guide (

Have you looked at PSADT’s [Get-LoggedOnUser] (Get-LoggedOnUser Β· PSAppDeployToolkit) function?