Powershell Exchange Delete old Phone Sync DevicesExporting specific fields with powershell's export-csvPowershell: Wanting Exchange statistics and running into (output) limitationsPowershell script to delete secondary SMTP addresses of Exchange 2010 Mail Contacts(Powershell) Method to return a list of groups where a specific user has 'write member' securityPowershell pipe exporting to csv is loosing dataPowershell Script to output all Distribution groups and nested groups into a csvHow to receive email notification of non-AD joined DHCP leases?Powrshell Script to read the Windows Secutiry logs and filter Elevation type 196 and 1937Powershell List Users who have RDS User CalError while running powershell script to back up DNS Zones
Can a human be transformed into a Mind Flayer?
How can I deal with uncomfortable silence from my partner?
What is the purpose of bonds within an investment portfolio?
Proving that a Russian cryptographic standard is too structured
Understanding "Current Draw" in terms of "Ohm's Law"
Why did Intel abandon unified CPU cache?
With Ubuntu 18.04, how can I have a hot corner that locks the computer?
color rows on table (Tabu package)
Generate basis elements of the Steenrod algebra
Is there a set of positive integers of density 1 which contains no infinite arithmetic progression?
Russian word for a male zebra
The Frozen Wastes
Excel division by 0 error when trying to average results of formulas
What is this airplane?
Why was this person allowed to become Grand Maester?
Advantages of the Exponential Family: why should we study it and use it?
Is this a bug in plotting step functions?
How to “listen” to existing circuit
Why Does Mama Coco Look Old After Going to the Other World?
How do free-speech protections in the United States apply in public to corporate misrepresentations?
I have a problematic assistant manager, but I can't fire him
Teaching a class likely meant to inflate the GPA of student athletes
Is it possible to have a wealthy country without a middle class?
Return a String containing only alphabets without spaces
Powershell Exchange Delete old Phone Sync Devices
Exporting specific fields with powershell's export-csvPowershell: Wanting Exchange statistics and running into (output) limitationsPowershell script to delete secondary SMTP addresses of Exchange 2010 Mail Contacts(Powershell) Method to return a list of groups where a specific user has 'write member' securityPowershell pipe exporting to csv is loosing dataPowershell Script to output all Distribution groups and nested groups into a csvHow to receive email notification of non-AD joined DHCP leases?Powrshell Script to read the Windows Secutiry logs and filter Elevation type 196 and 1937Powershell List Users who have RDS User CalError while running powershell script to back up DNS Zones
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to run a Powershell Script that will clean up any Phones that haven't synced in at least 110 days with the Exchange 2013 Server.
My code will pull the data and export it to CSV but when I try to pipe in the Remove-MobileDevice command to delete the devices the script fails to do so. Nothing I found on the Internet has been of much help so far. Most are using the outdated ActiveSyncDevice cmdlets.
Here's my code, I'm new to PowerShell and appreciate any help:
Get-MobileDevice -result unlimited | Get-MobileDeviceStatistics | where $_.LastSuccessSync -le (Get-Date).AddDays(“-110”) | select devicetype, deviceidentity, deviceos, deviceuseragent, identity | Export-csv C:PhoneSyncLogsStale_Devices_110days_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv | foreach (Remove-MobileDevice -Identity DeviceUserAgent -confirm:$false)
powershell
migrated from stackoverflow.com Mar 23 '17 at 14:13
This question came from our site for professional and enthusiast programmers.
add a comment |
I'm trying to run a Powershell Script that will clean up any Phones that haven't synced in at least 110 days with the Exchange 2013 Server.
My code will pull the data and export it to CSV but when I try to pipe in the Remove-MobileDevice command to delete the devices the script fails to do so. Nothing I found on the Internet has been of much help so far. Most are using the outdated ActiveSyncDevice cmdlets.
Here's my code, I'm new to PowerShell and appreciate any help:
Get-MobileDevice -result unlimited | Get-MobileDeviceStatistics | where $_.LastSuccessSync -le (Get-Date).AddDays(“-110”) | select devicetype, deviceidentity, deviceos, deviceuseragent, identity | Export-csv C:PhoneSyncLogsStale_Devices_110days_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv | foreach (Remove-MobileDevice -Identity DeviceUserAgent -confirm:$false)
powershell
migrated from stackoverflow.com Mar 23 '17 at 14:13
This question came from our site for professional and enthusiast programmers.
One issue is that you are attempting pipe to your finalforeach
after exporting your csv. Probably worth while to break your one-liner into an a multiple line script for clarity.
– BenH
Jan 18 '17 at 18:52
Did you inspect the CSV file?
– Jeroen Heier
Jan 18 '17 at 18:58
I tried removing the export and it still bombs out with this error:The mobile device DeviceUserAgent cannot be found. + CategoryInfo : NotSpecified: (:) [Remove-MobileDevice], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=WEBMAIL,RequestId=771c3306-817b-4049-a076-e398d73fbaed,TimeStamp=1/18/2017 6:59:23 PM] [FailureCategory=Cmdlet -ManagementObjectNotFoundException] DFB3D711,Microsoft.Exchange.Management.Tasks.RemoveMobileDevice + PSComputerName : webmail.server.com
– djl236
Jan 18 '17 at 19:00
Yes, the CSV contains the device I want deleted.
– djl236
Jan 18 '17 at 19:02
That issue is because foreach object you are passing you are statically defining the Identity as "DeviceUserAgent" with this:-Identity DeviceUserAgent
Try changing it to-Identity $_.DeviceUserAgent
.
– BenH
Jan 18 '17 at 21:34
add a comment |
I'm trying to run a Powershell Script that will clean up any Phones that haven't synced in at least 110 days with the Exchange 2013 Server.
My code will pull the data and export it to CSV but when I try to pipe in the Remove-MobileDevice command to delete the devices the script fails to do so. Nothing I found on the Internet has been of much help so far. Most are using the outdated ActiveSyncDevice cmdlets.
Here's my code, I'm new to PowerShell and appreciate any help:
Get-MobileDevice -result unlimited | Get-MobileDeviceStatistics | where $_.LastSuccessSync -le (Get-Date).AddDays(“-110”) | select devicetype, deviceidentity, deviceos, deviceuseragent, identity | Export-csv C:PhoneSyncLogsStale_Devices_110days_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv | foreach (Remove-MobileDevice -Identity DeviceUserAgent -confirm:$false)
powershell
I'm trying to run a Powershell Script that will clean up any Phones that haven't synced in at least 110 days with the Exchange 2013 Server.
My code will pull the data and export it to CSV but when I try to pipe in the Remove-MobileDevice command to delete the devices the script fails to do so. Nothing I found on the Internet has been of much help so far. Most are using the outdated ActiveSyncDevice cmdlets.
Here's my code, I'm new to PowerShell and appreciate any help:
Get-MobileDevice -result unlimited | Get-MobileDeviceStatistics | where $_.LastSuccessSync -le (Get-Date).AddDays(“-110”) | select devicetype, deviceidentity, deviceos, deviceuseragent, identity | Export-csv C:PhoneSyncLogsStale_Devices_110days_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv | foreach (Remove-MobileDevice -Identity DeviceUserAgent -confirm:$false)
powershell
powershell
asked Jan 18 '17 at 18:37
djl236
migrated from stackoverflow.com Mar 23 '17 at 14:13
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Mar 23 '17 at 14:13
This question came from our site for professional and enthusiast programmers.
One issue is that you are attempting pipe to your finalforeach
after exporting your csv. Probably worth while to break your one-liner into an a multiple line script for clarity.
– BenH
Jan 18 '17 at 18:52
Did you inspect the CSV file?
– Jeroen Heier
Jan 18 '17 at 18:58
I tried removing the export and it still bombs out with this error:The mobile device DeviceUserAgent cannot be found. + CategoryInfo : NotSpecified: (:) [Remove-MobileDevice], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=WEBMAIL,RequestId=771c3306-817b-4049-a076-e398d73fbaed,TimeStamp=1/18/2017 6:59:23 PM] [FailureCategory=Cmdlet -ManagementObjectNotFoundException] DFB3D711,Microsoft.Exchange.Management.Tasks.RemoveMobileDevice + PSComputerName : webmail.server.com
– djl236
Jan 18 '17 at 19:00
Yes, the CSV contains the device I want deleted.
– djl236
Jan 18 '17 at 19:02
That issue is because foreach object you are passing you are statically defining the Identity as "DeviceUserAgent" with this:-Identity DeviceUserAgent
Try changing it to-Identity $_.DeviceUserAgent
.
– BenH
Jan 18 '17 at 21:34
add a comment |
One issue is that you are attempting pipe to your finalforeach
after exporting your csv. Probably worth while to break your one-liner into an a multiple line script for clarity.
– BenH
Jan 18 '17 at 18:52
Did you inspect the CSV file?
– Jeroen Heier
Jan 18 '17 at 18:58
I tried removing the export and it still bombs out with this error:The mobile device DeviceUserAgent cannot be found. + CategoryInfo : NotSpecified: (:) [Remove-MobileDevice], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=WEBMAIL,RequestId=771c3306-817b-4049-a076-e398d73fbaed,TimeStamp=1/18/2017 6:59:23 PM] [FailureCategory=Cmdlet -ManagementObjectNotFoundException] DFB3D711,Microsoft.Exchange.Management.Tasks.RemoveMobileDevice + PSComputerName : webmail.server.com
– djl236
Jan 18 '17 at 19:00
Yes, the CSV contains the device I want deleted.
– djl236
Jan 18 '17 at 19:02
That issue is because foreach object you are passing you are statically defining the Identity as "DeviceUserAgent" with this:-Identity DeviceUserAgent
Try changing it to-Identity $_.DeviceUserAgent
.
– BenH
Jan 18 '17 at 21:34
One issue is that you are attempting pipe to your final
foreach
after exporting your csv. Probably worth while to break your one-liner into an a multiple line script for clarity.– BenH
Jan 18 '17 at 18:52
One issue is that you are attempting pipe to your final
foreach
after exporting your csv. Probably worth while to break your one-liner into an a multiple line script for clarity.– BenH
Jan 18 '17 at 18:52
Did you inspect the CSV file?
– Jeroen Heier
Jan 18 '17 at 18:58
Did you inspect the CSV file?
– Jeroen Heier
Jan 18 '17 at 18:58
I tried removing the export and it still bombs out with this error:
The mobile device DeviceUserAgent cannot be found. + CategoryInfo : NotSpecified: (:) [Remove-MobileDevice], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=WEBMAIL,RequestId=771c3306-817b-4049-a076-e398d73fbaed,TimeStamp=1/18/2017 6:59:23 PM] [FailureCategory=Cmdlet -ManagementObjectNotFoundException] DFB3D711,Microsoft.Exchange.Management.Tasks.RemoveMobileDevice + PSComputerName : webmail.server.com
– djl236
Jan 18 '17 at 19:00
I tried removing the export and it still bombs out with this error:
The mobile device DeviceUserAgent cannot be found. + CategoryInfo : NotSpecified: (:) [Remove-MobileDevice], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=WEBMAIL,RequestId=771c3306-817b-4049-a076-e398d73fbaed,TimeStamp=1/18/2017 6:59:23 PM] [FailureCategory=Cmdlet -ManagementObjectNotFoundException] DFB3D711,Microsoft.Exchange.Management.Tasks.RemoveMobileDevice + PSComputerName : webmail.server.com
– djl236
Jan 18 '17 at 19:00
Yes, the CSV contains the device I want deleted.
– djl236
Jan 18 '17 at 19:02
Yes, the CSV contains the device I want deleted.
– djl236
Jan 18 '17 at 19:02
That issue is because foreach object you are passing you are statically defining the Identity as "DeviceUserAgent" with this:
-Identity DeviceUserAgent
Try changing it to -Identity $_.DeviceUserAgent
.– BenH
Jan 18 '17 at 21:34
That issue is because foreach object you are passing you are statically defining the Identity as "DeviceUserAgent" with this:
-Identity DeviceUserAgent
Try changing it to -Identity $_.DeviceUserAgent
.– BenH
Jan 18 '17 at 21:34
add a comment |
1 Answer
1
active
oldest
votes
Can I provide a better (automatically) solution which is build into Exchange? Since Exchange 2013/2016 Microsoft added the EasMaxInactivityForDeviceCleanup value to the throttling policy and described it here as:
The EasMaxInactivityForDeviceCleanup parameter specifies the length of
time that a user's device partnerships will remain active. By default,
there is no limit to the number of days that a user's device
partnerships will remain active. Use this value if you want to
minimize the amount of inactive device partnerships in your
organization. To use this setting, specify a value in days since the
user's last sync time to cause the device partnership to be removed.
So if I would be you, I would create a new throttling policy as explained here and assign that to your users. After that is in place and if a user is adding a new device, the Exchange server will check the configured devices and will automatically delete the unused one, during the adding from the new device. Then you do not need to run a script, the server will mostly take care of them automatically.
Thank you for that solution, which will be great going forward, but what about the devices there now? I'd like to get this script working to purge them. EDIT: It says this cmdlet is only available on Ex2016, we are using 2013.
– djl236
Jan 18 '17 at 19:56
I personally would wait as you said you are a new to powershell. I personally wouldn´t risk to delete any administration/monitoring devices if you haven´t the needed skills yet. The point is, how often did the user get new "toys" to play with? I would wait here. But if you really need a script you can check the one in the URL above (or here is it again).
– BastianW
Jan 18 '17 at 19:59
Its policy from management. Its currently done manually by hand by logging into each user's mailbox. I'm just trying to automate the process. The problem with the script in your URL is when I try to add exporting the results to CSV it fails.
– djl236
Jan 18 '17 at 20:02
lol someone who doesn't know scripting. I use VBScript a lot more and am just getting into PowerShell so still getting a hang for the syntax and what not. Thanks for the link.
– djl236
Jan 18 '17 at 20:12
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f840172%2fpowershell-exchange-delete-old-phone-sync-devices%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Can I provide a better (automatically) solution which is build into Exchange? Since Exchange 2013/2016 Microsoft added the EasMaxInactivityForDeviceCleanup value to the throttling policy and described it here as:
The EasMaxInactivityForDeviceCleanup parameter specifies the length of
time that a user's device partnerships will remain active. By default,
there is no limit to the number of days that a user's device
partnerships will remain active. Use this value if you want to
minimize the amount of inactive device partnerships in your
organization. To use this setting, specify a value in days since the
user's last sync time to cause the device partnership to be removed.
So if I would be you, I would create a new throttling policy as explained here and assign that to your users. After that is in place and if a user is adding a new device, the Exchange server will check the configured devices and will automatically delete the unused one, during the adding from the new device. Then you do not need to run a script, the server will mostly take care of them automatically.
Thank you for that solution, which will be great going forward, but what about the devices there now? I'd like to get this script working to purge them. EDIT: It says this cmdlet is only available on Ex2016, we are using 2013.
– djl236
Jan 18 '17 at 19:56
I personally would wait as you said you are a new to powershell. I personally wouldn´t risk to delete any administration/monitoring devices if you haven´t the needed skills yet. The point is, how often did the user get new "toys" to play with? I would wait here. But if you really need a script you can check the one in the URL above (or here is it again).
– BastianW
Jan 18 '17 at 19:59
Its policy from management. Its currently done manually by hand by logging into each user's mailbox. I'm just trying to automate the process. The problem with the script in your URL is when I try to add exporting the results to CSV it fails.
– djl236
Jan 18 '17 at 20:02
lol someone who doesn't know scripting. I use VBScript a lot more and am just getting into PowerShell so still getting a hang for the syntax and what not. Thanks for the link.
– djl236
Jan 18 '17 at 20:12
add a comment |
Can I provide a better (automatically) solution which is build into Exchange? Since Exchange 2013/2016 Microsoft added the EasMaxInactivityForDeviceCleanup value to the throttling policy and described it here as:
The EasMaxInactivityForDeviceCleanup parameter specifies the length of
time that a user's device partnerships will remain active. By default,
there is no limit to the number of days that a user's device
partnerships will remain active. Use this value if you want to
minimize the amount of inactive device partnerships in your
organization. To use this setting, specify a value in days since the
user's last sync time to cause the device partnership to be removed.
So if I would be you, I would create a new throttling policy as explained here and assign that to your users. After that is in place and if a user is adding a new device, the Exchange server will check the configured devices and will automatically delete the unused one, during the adding from the new device. Then you do not need to run a script, the server will mostly take care of them automatically.
Thank you for that solution, which will be great going forward, but what about the devices there now? I'd like to get this script working to purge them. EDIT: It says this cmdlet is only available on Ex2016, we are using 2013.
– djl236
Jan 18 '17 at 19:56
I personally would wait as you said you are a new to powershell. I personally wouldn´t risk to delete any administration/monitoring devices if you haven´t the needed skills yet. The point is, how often did the user get new "toys" to play with? I would wait here. But if you really need a script you can check the one in the URL above (or here is it again).
– BastianW
Jan 18 '17 at 19:59
Its policy from management. Its currently done manually by hand by logging into each user's mailbox. I'm just trying to automate the process. The problem with the script in your URL is when I try to add exporting the results to CSV it fails.
– djl236
Jan 18 '17 at 20:02
lol someone who doesn't know scripting. I use VBScript a lot more and am just getting into PowerShell so still getting a hang for the syntax and what not. Thanks for the link.
– djl236
Jan 18 '17 at 20:12
add a comment |
Can I provide a better (automatically) solution which is build into Exchange? Since Exchange 2013/2016 Microsoft added the EasMaxInactivityForDeviceCleanup value to the throttling policy and described it here as:
The EasMaxInactivityForDeviceCleanup parameter specifies the length of
time that a user's device partnerships will remain active. By default,
there is no limit to the number of days that a user's device
partnerships will remain active. Use this value if you want to
minimize the amount of inactive device partnerships in your
organization. To use this setting, specify a value in days since the
user's last sync time to cause the device partnership to be removed.
So if I would be you, I would create a new throttling policy as explained here and assign that to your users. After that is in place and if a user is adding a new device, the Exchange server will check the configured devices and will automatically delete the unused one, during the adding from the new device. Then you do not need to run a script, the server will mostly take care of them automatically.
Can I provide a better (automatically) solution which is build into Exchange? Since Exchange 2013/2016 Microsoft added the EasMaxInactivityForDeviceCleanup value to the throttling policy and described it here as:
The EasMaxInactivityForDeviceCleanup parameter specifies the length of
time that a user's device partnerships will remain active. By default,
there is no limit to the number of days that a user's device
partnerships will remain active. Use this value if you want to
minimize the amount of inactive device partnerships in your
organization. To use this setting, specify a value in days since the
user's last sync time to cause the device partnership to be removed.
So if I would be you, I would create a new throttling policy as explained here and assign that to your users. After that is in place and if a user is adding a new device, the Exchange server will check the configured devices and will automatically delete the unused one, during the adding from the new device. Then you do not need to run a script, the server will mostly take care of them automatically.
answered Jan 18 '17 at 19:53
BastianWBastianW
2,68341533
2,68341533
Thank you for that solution, which will be great going forward, but what about the devices there now? I'd like to get this script working to purge them. EDIT: It says this cmdlet is only available on Ex2016, we are using 2013.
– djl236
Jan 18 '17 at 19:56
I personally would wait as you said you are a new to powershell. I personally wouldn´t risk to delete any administration/monitoring devices if you haven´t the needed skills yet. The point is, how often did the user get new "toys" to play with? I would wait here. But if you really need a script you can check the one in the URL above (or here is it again).
– BastianW
Jan 18 '17 at 19:59
Its policy from management. Its currently done manually by hand by logging into each user's mailbox. I'm just trying to automate the process. The problem with the script in your URL is when I try to add exporting the results to CSV it fails.
– djl236
Jan 18 '17 at 20:02
lol someone who doesn't know scripting. I use VBScript a lot more and am just getting into PowerShell so still getting a hang for the syntax and what not. Thanks for the link.
– djl236
Jan 18 '17 at 20:12
add a comment |
Thank you for that solution, which will be great going forward, but what about the devices there now? I'd like to get this script working to purge them. EDIT: It says this cmdlet is only available on Ex2016, we are using 2013.
– djl236
Jan 18 '17 at 19:56
I personally would wait as you said you are a new to powershell. I personally wouldn´t risk to delete any administration/monitoring devices if you haven´t the needed skills yet. The point is, how often did the user get new "toys" to play with? I would wait here. But if you really need a script you can check the one in the URL above (or here is it again).
– BastianW
Jan 18 '17 at 19:59
Its policy from management. Its currently done manually by hand by logging into each user's mailbox. I'm just trying to automate the process. The problem with the script in your URL is when I try to add exporting the results to CSV it fails.
– djl236
Jan 18 '17 at 20:02
lol someone who doesn't know scripting. I use VBScript a lot more and am just getting into PowerShell so still getting a hang for the syntax and what not. Thanks for the link.
– djl236
Jan 18 '17 at 20:12
Thank you for that solution, which will be great going forward, but what about the devices there now? I'd like to get this script working to purge them. EDIT: It says this cmdlet is only available on Ex2016, we are using 2013.
– djl236
Jan 18 '17 at 19:56
Thank you for that solution, which will be great going forward, but what about the devices there now? I'd like to get this script working to purge them. EDIT: It says this cmdlet is only available on Ex2016, we are using 2013.
– djl236
Jan 18 '17 at 19:56
I personally would wait as you said you are a new to powershell. I personally wouldn´t risk to delete any administration/monitoring devices if you haven´t the needed skills yet. The point is, how often did the user get new "toys" to play with? I would wait here. But if you really need a script you can check the one in the URL above (or here is it again).
– BastianW
Jan 18 '17 at 19:59
I personally would wait as you said you are a new to powershell. I personally wouldn´t risk to delete any administration/monitoring devices if you haven´t the needed skills yet. The point is, how often did the user get new "toys" to play with? I would wait here. But if you really need a script you can check the one in the URL above (or here is it again).
– BastianW
Jan 18 '17 at 19:59
Its policy from management. Its currently done manually by hand by logging into each user's mailbox. I'm just trying to automate the process. The problem with the script in your URL is when I try to add exporting the results to CSV it fails.
– djl236
Jan 18 '17 at 20:02
Its policy from management. Its currently done manually by hand by logging into each user's mailbox. I'm just trying to automate the process. The problem with the script in your URL is when I try to add exporting the results to CSV it fails.
– djl236
Jan 18 '17 at 20:02
lol someone who doesn't know scripting. I use VBScript a lot more and am just getting into PowerShell so still getting a hang for the syntax and what not. Thanks for the link.
– djl236
Jan 18 '17 at 20:12
lol someone who doesn't know scripting. I use VBScript a lot more and am just getting into PowerShell so still getting a hang for the syntax and what not. Thanks for the link.
– djl236
Jan 18 '17 at 20:12
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f840172%2fpowershell-exchange-delete-old-phone-sync-devices%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
One issue is that you are attempting pipe to your final
foreach
after exporting your csv. Probably worth while to break your one-liner into an a multiple line script for clarity.– BenH
Jan 18 '17 at 18:52
Did you inspect the CSV file?
– Jeroen Heier
Jan 18 '17 at 18:58
I tried removing the export and it still bombs out with this error:
The mobile device DeviceUserAgent cannot be found. + CategoryInfo : NotSpecified: (:) [Remove-MobileDevice], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=WEBMAIL,RequestId=771c3306-817b-4049-a076-e398d73fbaed,TimeStamp=1/18/2017 6:59:23 PM] [FailureCategory=Cmdlet -ManagementObjectNotFoundException] DFB3D711,Microsoft.Exchange.Management.Tasks.RemoveMobileDevice + PSComputerName : webmail.server.com
– djl236
Jan 18 '17 at 19:00
Yes, the CSV contains the device I want deleted.
– djl236
Jan 18 '17 at 19:02
That issue is because foreach object you are passing you are statically defining the Identity as "DeviceUserAgent" with this:
-Identity DeviceUserAgent
Try changing it to-Identity $_.DeviceUserAgent
.– BenH
Jan 18 '17 at 21:34