How do you impersonate an Active Directory user in Powershell?

I’m trying to run powershell commands through a web interface (ASP.NET/C#) in order to create mailboxes/etc on Exchange 2007. When I run the page using Visual Studio (Cassini), the page loads up correctly. However, when I run it on IIS (v5.1), I get the error “unknown user name or bad password”. The biggest problem that I noticed was that Powershell was logged in as ASPNET instead of my Active Directory Account. How do I force my Powershell session to be authenticated with another Active Directory Account?

Can’t get AWS Elastic Beanstalk Command Line Tool to work on Windows 8. Get the following PowerShell error?

Add-Type : Cannot add type due to the following exception: Compiler executable
file csc.exe cannot be found.. Verify that version 3.5 of the Microsoft .NET
Framework is installed. On 64-bit versions of Windows, the WOW64 component is
also required.
At C:UsersAlbertDocumentsWindowsPowerShellModulesAWSDevToolsAWSDevTools.
ps1:315 char:1
+ Add-Type -Language CSharpVersion3 -TypeDefinition $awsSource
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], InvalidOperationEx
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Power

Forcing certain code to always run on the same thread

We have an old 3rd party system (let’s call it Junksoft® 95) that we interface with via PowerShell (it exposes a COM object) and I’m in the process of wrapping it in a REST API (ASP.NET Framework 4.8 and WebAPI 2). I use the System.Management.Automation nuget package to create a PowerShell in which I instantiate Junksoft’s COM API as a dynamic object that I then use:

Running powershell script within python script, how to make python print the powershell output while it is running

I am writing a python script which checks various conditions and runs a powershell script accordingly to help me automate migration from windows XP to windows 7. The powershell script gives its own output giving the user updates as to what is happening. I would like to take the output of the powershell script and print it as output of the python script. I have looked around at some questions which seem to want to do the same thing but they don’t seem to be working for me. Initially I tried using