You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Planning to use this for when a specific account logs into a specific computer. Using Task scheduler to fire off the following .ps1 script:
$PCName=(Get-CimInstance -ClassName Win32_ComputerSystem).Name
$CurrentDate=Get-Date
Invoke-Command -ComputerName -ScriptBlock {New-BurntToastNotification -Text "SPECIFIED ACCOUNT HAS LOGGED IN TO $PCName ON $CurrentDate" -Sound 'Alarm2'}
Currently the variables are missing when the toast notification comes up.
Thanks :)
The text was updated successfully, but these errors were encountered:
What you're running into there is a scoping issue. When running Invoke-Command the ScriptBlock runs in an environment where those variables do not exist.
The "using" scope should fix this, e.g. "SPECIFIED ACCOUNT HAS LOGGED IN TO $using:PCName ON $using:CurrentDate"
Planning to use this for when a specific account logs into a specific computer. Using Task scheduler to fire off the following .ps1 script:
$PCName=(Get-CimInstance -ClassName Win32_ComputerSystem).Name
$CurrentDate=Get-Date
Invoke-Command -ComputerName -ScriptBlock {New-BurntToastNotification -Text "SPECIFIED ACCOUNT HAS LOGGED IN TO $PCName ON $CurrentDate" -Sound 'Alarm2'}
Currently the variables are missing when the toast notification comes up.
Thanks :)
The text was updated successfully, but these errors were encountered: