0 votes

I am trying to create a custom command that will wipe the users phones. The it seems the power shell is not taking the Variable %username%. Please see below

Import-Module Adaxes
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Support
$Target = %username%
Get-ActiveSyncDeviceStatistics -Mailbox $Target | foreach { Clear-ActiveSyncDevice $_.Identity -Confirm }

IS there and way to get it to take "$Target" in ther Get command?

by (40 points)

1 Answer

0 votes
by (216k points)

Hello, you need to enclose the %username% value reference in double quotes. Also, there's no need to import the Adaxes PowerShell module since you are not using any of its cmdlets.

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Support
$Target = "%username%"
Get-ActiveSyncDeviceStatistics -Mailbox $Target | foreach { Clear-ActiveSyncDevice $_.Identity }
0

Ok that seems to work with the "" Thank you . Now i am getting this error, "Cannot invoke this function because the current host does not implement it." Any ideas would be greatly appreciated.

0

The issue is in the -Confirm parameter. It forces the Clear-ActiveSyncDevice cmdlet to show a confirmation before wiping ActiVeSync devices, however Adaxes Custom Commands, Business Rules and Scheduled Tasks do not support prompting for confirmation from PowerShell scripts. Removing this switch will resolve the issue (see the updated script in the post above).

Related questions

0 votes
1 answer

Is there a way to pull a report within Adaxes to find out how many computer objects a user will have associated to them?

asked Mar 2, 2022 by Tarun Sharma (20 points)
0 votes
1 answer

Hello, We need a report or a custom command that export all Active Sync devices details. Is there a way to do it ? Thanks :-) Michel

asked Feb 11, 2022 by zemitch (200 points)
0 votes
1 answer

For Office 365 Mailboxes, I get the following error:

asked Aug 27, 2019 by yourpp (540 points)
0 votes
1 answer

Hi after the user acount is created in Active Directory I need the business rule to pause for 30mins for the azure sync to take place before the rule can continue to add the 365 license.

asked May 24 by johanpr (120 points)
0 votes
1 answer

Maybe there is a better way to accomplish this, so I'm open to suggestion. We are in a hybrid setup between onprem and M365. When we create a new user, they are ... command in the previous step, right? If needed, I can provide the full script. Thanks!

asked Nov 2, 2023 by AndrewMeyer (20 points)
3,549 questions
3,240 answers
8,232 comments
547,814 users