locked
return failed result RRS feed

  • Question

  • i have a script to create some adressbooks in exchange and so on, now i need to check if the script has run like expected. 
    i want to create a $result with Get command so i need to do the following : 

    example : 

    Get-Addresslist $customer* | fl name
    Get-GlobalAddressList -identity $customer* | fl name
    Get-OfflineAddressBook -identity $customer* | fl name
    Get-AddressBookPolicy -identity $customer* | fl name

    no i need to add that if i get back an addresslist the result should be "OK"
    and when my Get command does not return any results (this means that the script has failed) i want to see "Failed" 

    anybody know how to do this?


    Thursday, June 21, 2018 10:56 AM

All replies

  • if(Get-Addresslist $customer*){}else{'failed'}


    \_(ツ)_/

    Thursday, June 21, 2018 11:17 AM
  • thanks this works, perfect



    Thursday, June 21, 2018 12:48 PM
  • You need to learn PowerShell before asking questions.

    if(Get-Addresslist $customer*){'Ok'}else{'failed'}


    \_(ツ)_/

    Thursday, June 21, 2018 12:54 PM