Hi,
I hope someone can spot the error:
This is a small function inside a bigger script.
I want it to increment $i everytime it iterate the foreach, but i cant get it to work. If i run only the line where $i++ is present, it will increment.
The message arriving to the users, so it works fine, its just ignoring the $i++
$i = 0
function Message {
start-job -Name Col01 -InitializationScript{Import-Module RemoteDesktop} -ScriptBlock{$Users = Get-RDUserSession -ConnectionBroker $ActiveConnectionBroker -CollectionName "col01"
foreach ($User in $Users) {
Send-RDUserMessage -UnifiedSessionID $User.UnifiedSessionId -HostServer $User.HostServer -MessageTitle "Info" -MessageBody $using:message
$i++
}
}
}
Varun SetiaPosted Oct 24, 2020, 12:03 AM
jesperPosted Oct 23, 2020, 5:22 PM
Varun SetiaPosted Oct 22, 2020, 12:36 AM
Varun SetiaPosted Oct 19, 2020, 11:33 AM
jesperPosted Oct 19, 2020, 10:49 AM
Varun SetiaPosted Oct 19, 2020, 1:02 AM
jesperPosted Oct 18, 2020, 10:51 AM
Varun SetiaPosted Oct 18, 2020, 10:23 AM