I have the following script.<\/p>\n
$CSVData = Import-Csv C:\\mdm\\import.csv For some reason, the Set-CasMailbox -identity $User.EmailAddress -ActiveSyncBlockedDeviceIDs $_.DeviceID is not processing.<\/p>\n If i use the following script<\/p>\n $CSVData = Import-Csv C:\\mdm\\import.csv If anyone could offer any assistance I’d be most grateful.<\/p>\n Thank you<\/p>","upvoteCount":5,"answerCount":9,"datePublished":"2020-07-06T05:35:38.000Z","author":{"@type":"Person","name":"alistaircarr","url":"https://community.spiceworks.com/u/alistaircarr"},"acceptedAnswer":{"@type":"Answer","text":" like so in theory:<\/p>\n i have no access to those cmdlets so I can not test this for you<\/p>\n I have the following script.<\/p>\n $CSVData = Import-Csv C:\\mdm\\import.csv For some reason, the Set-CasMailbox -identity $User.EmailAddress -ActiveSyncBlockedDeviceIDs $_.DeviceID is not processing.<\/p>\n If i use the following script<\/p>\n $CSVData = Import-Csv C:\\mdm\\import.csv If anyone could offer any assistance I’d be most grateful.<\/p>\n Thank you<\/p>","upvoteCount":5,"datePublished":"2020-07-06T05:35:38.000Z","url":"https://community.spiceworks.com/t/pipe-issue/768254/1","author":{"@type":"Person","name":"alistaircarr","url":"https://community.spiceworks.com/u/alistaircarr"}},{"@type":"Answer","text":" If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
\nForEach ($User in $CSVData) {
\nGet-MobileDevice -Mailbox $User.EmailAddress | Where {$.FirstSyncTime -lt (Get-Date -Hour 0 -Minute 00 -Second 00).AddDays(-22)} |
\nForEach-Object {
\nSet-CasMailbox -identity $User.EmailAddress -ActiveSyncBlockedDeviceIDs $<\/em>.DeviceID
\n| Remove-MobileDevice -Confirm:$False -whatif
\n}}<\/p>\n
\nForEach ($User in $CSVData) {
\nGet-MobileDevice -Mailbox $User.EmailAddress | Where {$.FirstSyncTime -lt (Get-Date -Hour 0 -Minute 00 -Second 00).AddDays(-22)} |
\nForEach-Object {
\n$<\/em>.DeviceId
\n}
\n}
\nIt outputs a list of the Active Sync Device ID\"s so unsure as to whats happening?<\/p>\n$users = Get-Content -Path “C:\\mdm\\removeusers.txt”\nWrite-Host $users\n\nforeach ($user in $users) {\n $EASBLOCKS = get-mobiledevice -mailbox $user | \n Where { $_.FirstSyncTime -lt (Get-Date -Hour 0 -Minute 00 -Second 00).AddDays(-80) } | \n Select-Object -ExpandProperty DeviceID\n\n foreach ($EASBLOCK in $EASBLOCKS) {\n Write-Host \"$user Active Sync ID to be moved to blocked is $EASBLOCK\"\n Set-CASMailbox -Identity $user -ActiveSyncBlockedDeviceIDs $EASBLOCK\n }\n}\n\nforeach ($user in $users) {\n $BLOCKEDIDS = Get-MobileDevice -mailbox $user | \n Where { $_.FirstSyncTime -lt (Get-Date -Hour 0 -Minute 00 -Second 00).AddDays(-80) } | \n Select-Object -ExpandProperty identity \n\n foreach ($BLOCKEDID in $BLOCKEDIDS) {\n Write-Host \"$BLOCKEDID belonging to $user has been removed\"\n Remove-MobileDevice -Identity $BLOCKEDID -Confirm:$false -whatif\n } \n} \n<\/code><\/pre>","upvoteCount":1,"datePublished":"2020-07-06T14:13:14.000Z","url":"https://community.spiceworks.com/t/pipe-issue/768254/9","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},"suggestedAnswer":[{"@type":"Answer","text":"
\nForEach ($User in $CSVData) {
\nGet-MobileDevice -Mailbox $User.EmailAddress | Where {$.FirstSyncTime -lt (Get-Date -Hour 0 -Minute 00 -Second 00).AddDays(-22)} |
\nForEach-Object {
\nSet-CasMailbox -identity $User.EmailAddress -ActiveSyncBlockedDeviceIDs $<\/em>.DeviceID
\n| Remove-MobileDevice -Confirm:$False -whatif
\n}}<\/p>\n
\nForEach ($User in $CSVData) {
\nGet-MobileDevice -Mailbox $User.EmailAddress | Where {$.FirstSyncTime -lt (Get-Date -Hour 0 -Minute 00 -Second 00).AddDays(-22)} |
\nForEach-Object {
\n$<\/em>.DeviceId
\n}
\n}
\nIt outputs a list of the Active Sync Device ID\"s so unsure as to whats happening?<\/p>\n