PowerTip: Easily Find the PowerShell ApartmentState

PowerTip: Easily Find the PowerShell ApartmentState

  • Comments 2
  • Likes

Summary: Easily find the Windows PowerShell ApartmentState.

Hey, Scripting Guy! Question How can I easily find the Windows PowerShell ApartmentState?

Hey, Scripting Guy! Answer Use the $host automatic variable, and select the ApartmentState property from the RunSpace object, as shown here.

PS C:\> $Host.RunSpace.ApartmentState

STA

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • This is a PowerTip that everyone who uses PowerShell needs to know. Cheers, Craig

  • @Craig Lussier thanks. I am glad you like the tip. I appreciate the feedback.