I apologize for the title, it doesn't say much. Please, just take a look at my script
$env:UserName
$FolderPath = C:\Users\UserCurrentlyLoggedIn\Desktop\5.1.0
# Function for the pop up message
function PopUp
{
Add-Type -AssemblyName System.Windows.Forms
$global:balmsg = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -id $pid).Path
$balmsg.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning
$balmsg.BalloonTipText = ‘Back up directories have reached maximum capacity!'
$balmsg.BalloonTipTitle = "Files may not be backed up!"
$balmsg.Visible = $true
$balmsg.ShowBalloonTip(100)
}
if ((((gci -path $FolderPath -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum/ 1MB),2) -gt 110.00)
{
PopUp
} Else {
'Size of folders is alright'
}
So, what I want to achieve with this hell of a mess, is basically: Script has to check the size of few folders located under C:\Users\UserCurentlyLoggedIn and if the size of those folder is bigger than (currently 110MB), then the PopUp message has to be shown. Otherwise, it has to do nothing. Overall it works if I provide the exact path to folders, however I would like to put it (the script) with GPO for Organization Unit, so I'm looking for the way to put the username of the person who is currently logged in on the machine at the time when the script is going to be run, in the place of "UserCurrentlyLoggedIn".
Again, I apologize for my gibberish explanation. I'm kind of new to scripting and stuff, and I have even a hard time explaining right what I want to do.
I appreciate all the help!