Hi All, I am very poor in PowerShell. Hence need some help from the experts.<\/p>\n
I guess this has to do with Array or functions. The requirement is to pass the values obtained in the powershell command.<\/p>\n
I will try to explain.<\/p>\n
On Exchange Server 2013 PowerShell if we run this command<\/p>\n
Get-CasMailbox [email protected]<\/a> | fl it will list all the properties for [email protected]<\/a> among with one of the property is “ActiveSyncAllowedDeviceIDs” which will have values like android3873,SAMSUNG2347,Nokia464 etc.<\/p>\n Then I have to take a note of the ActiveSyncAllowedDeviceIDs and run<\/p>\n Set-CasMailbox [email protected]<\/a> -ActiveSyncAllowedDeviceIDs @{Remove=“android3873”,“SAMSUNG2347”}<\/p>\n How do I compose a command that will automatically remove the ActiveSyncAllowedDeviceIDs other then BB* & WorxMail*<\/p>\n Requirement is to remove the devices by their DeviceIDs, except ones starting with BB* & WorxMail*<\/p>\n Thanks for your time, effort and knowledge.<\/p>\n @paul-the-psguru<\/a> @powershellpro<\/a><\/p>","upvoteCount":2,"answerCount":12,"datePublished":"2018-04-16T13:11:52.000Z","author":{"@type":"Person","name":"gautamkumar5","url":"https://community.spiceworks.com/u/gautamkumar5"},"suggestedAnswer":[{"@type":"Answer","text":" Hi All, I am very poor in PowerShell. Hence need some help from the experts.<\/p>\n I guess this has to do with Array or functions. The requirement is to pass the values obtained in the powershell command.<\/p>\n I will try to explain.<\/p>\n On Exchange Server 2013 PowerShell if we run this command<\/p>\n Get-CasMailbox [email protected]<\/a> | fl it will list all the properties for [email protected]<\/a> among with one of the property is “ActiveSyncAllowedDeviceIDs” which will have values like android3873,SAMSUNG2347,Nokia464 etc.<\/p>\n Then I have to take a note of the ActiveSyncAllowedDeviceIDs and run<\/p>\n Set-CasMailbox [email protected]<\/a> -ActiveSyncAllowedDeviceIDs @{Remove=“android3873”,“SAMSUNG2347”}<\/p>\n How do I compose a command that will automatically remove the ActiveSyncAllowedDeviceIDs other then BB* & WorxMail*<\/p>\n Requirement is to remove the devices by their DeviceIDs, except ones starting with BB* & WorxMail*<\/p>\n Thanks for your time, effort and knowledge.<\/p>\n @paul-the-psguru<\/a> @powershellpro<\/a><\/p>","upvoteCount":2,"datePublished":"2018-04-16T13:11:52.000Z","url":"https://community.spiceworks.com/t/how-to-compose-command-in-powershell/646377/1","author":{"@type":"Person","name":"gautamkumar5","url":"https://community.spiceworks.com/u/gautamkumar5"}},{"@type":"Answer","text":" Welcome!<\/p>\n If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>