Saturday, February 2, 2013

PowerShellASP: Combining PowerShell, ASP, and HTML using IIS 7.x


PowerShellASP websites have the ability to run PowerShell on remote computers, much the same way as using -computername and -credential.  The site can detect the visitors client and retrieve information about their computer in order for the restricted user to perform elevated functions like install IP-based printers.

Here is a sample .ps1x file portion which creates a web form, asks for a username and password which is able to connect via RWMI, detects the visitors IP address, which OS they're using, connects to it using remote WMI and displays the Windows version in the web browser.  This is just a sample of what system administrators can do via this great product.  I encourage those who wish to automate processes and give limited elevated functionality to their users to visit the PowerShell ASP website and leverage this tool.

<form method="POST" action="" enctype="multipart/ form-data">
Username:  <input type=text name="username" size="20"value="<%=$request['username']%>" />
Password: <input type=password name="password" size="20" value="<%=$request['password']%>" />
<input type=submit  value="Check OS Version" />
</form>
<%
if($request.HttpMethod -eq "POST") {
$remotehost = [net.IPAddress]::Parse($request.UserHostAddress)
$remoteIP = [System.Net.Dns]::GetHostAddresses($remotehost)| ? {$_.AddressFamily -eq "InterNetwork"}
$username = ("$remoteip" + "\" + $request['username'])
$securePassword = ConvertTo-SecureString $request['password'] -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PsCredential($username,$securePassword)
$session = new-PSSession -credential $Credentials -computer 192.168.1.145
$command = {Gwmi -Class Win32_OperatingSystem|convertto-html -fragment -property version}
$remote = Invoke-Command -session $session -scriptblock $command
write-host $remote}
%>

Facebook: Blocking Unwanted App Requests

Your Facebook friends may send you invites to try their game or application.  Some games reward players for sending requests after they've achieved a milestone, gained a new score, or finished for the day.  If they comply, then they'll be rewarded with virtual points, gold, loot, and/or other goodies.  You can filter these requests from your newsfeed while they can still fulfill their games requests and gain their virtual bonuses.   Here's how to hide these game/application requests:

1.  You receive an invitation to play a game.  Click on the game link:

2.  At the bottom right side of the application/game page, click on "View in App Center"


3. At the bottom right portion of the App page, click on Block:


 4.  Click Confirm to block the App/Game: (there will be a confirmation page after your click)


5.  If you wish to view all of the applications/games you have blocked and wish to manage that list, find the gear icon at the top right portion of your Facebook page and click on Account Settings:


6.  Locate Blocking on the left side and click on it: 


7.  Towards the bottom of the Block page, you'll find all the blocked applications.  You can add more by typing in the name of the program and pressing the Enter key.  You can also choose to unblock programs by clicking on Unblock next to the application name.