Hi, @Boopathi S
Thank you for posting in Microsoft Q&A forum.
I test your first powershell command in my lab, it works well, the only thing I changed is to remove the semi-parentheses after "if".
Here is my configuration and results:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.