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
0 answers

I'm currently trying to create a workflow that has been requested by our business. One of our IT departments is responsible for wiping devices. This can be done through Intune, ... "Failing to send Wipe command. Contact Core Services.", "Warning") return } }

asked Jan 6 by alexalex (40 points)
0 votes
1 answer

Is there a comparison between the OnPrem user object and Entra user object in the built-in condition? Which determines the most recent inactivity from both environments. Or should a choice be made between the OnPrem domain or Entra based on the Activity scope?

asked Dec 13, 2024 by IwistIT (40 points)
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)
3,600 questions
3,288 answers
8,329 comments
548,313 users