Posts RSS Comments RSS 117 Posts and 170 Comments till now

Get-CitrixApplication.ps1 (Citrix Top 10)

This script returns Citrix Application Objects.
- With no -AppName passed it will return All application Objects
- With -AppName it will return all apps that match (regex.)

  1. # Get-CitrixApplication.ps1
  2. # Brandon Shell [MVP]
  3. # www.bsonposh.com
  4. # Returns Citrix Application Objects for AppName passed or RegEx
  5. Param($AppName=".*",$server=$env:ComputerName)
  6. $type = [system.Type]::GetTypeFromProgID("MetaframeCOM.MetaFrameFarm",$server)
  7. $farm = [system.Activator]::CreateInstance($type)
  8. $farm.Initialize(1)
  9. $farm.Applications | ?{($_.AppName -match $AppName) -or ($_.BrowserName -match $AppName)}

SpecOps and Group Policies… What a match!

Special Operations Software has created an Incredible marriage of Powershell and Group Policy. Please take some time to watch these Demos. AWESOME!

Specops Command done by Darren Mar-Elia:
http://www.specopssoft.com/powershell/specopscommand-sdm.wmv

Specops Deploy done by Derek Melber:
http://www.specopssoft.com/products/specopsdeploy/specops_deploy.wmv

Kill-UserProcess (my first whatif Script)

There was a post on the forums about Killing all the processes for a user so I decided to write a script for it… sounded like something I could use. I thought about using get-process or [System.Diagnostics.Process] for remoting, but instead I went with WMI.

Below is the script and here are some example usages

Get User Processes on Server
PS> kill-userProcess -server Serverx -user jloser
Get User Processes on Server and Kill using -whatif
PS> kill-userProcess -server Serverx -user jloser -kill -whatif
Get User Processes on Server and kill them
PS> kill-userProcess -server Serverx -user jloser -kill
Get User Process on Server Kill/Whatif
PS> kill-userProcess -server Serverx -user jloser -process explorer.exe -kill -whatif
Get User Process on Server just kill
PS> kill-userProcess -server Serverx -user jloser -process explorer.exe -kill

[code]
function Kill-UserProcess{
param([string]$server,[string]$user,[string]$process,[switch]$Kill,[switch]$whatif)
if($server){$processes = Get-WmiObject Win32\_Process -ComputerName $server}
else{$processes = Get-WmiObject Win32\_Process}
if($user){
if($kill){if(!$process){Write-Host “Killing all Processes for User [$user]“}}
foreach($p in $processes){
if($p.GetOwner().user -match “$user”){
if($process){
if($p.Name -match “$process”){
if($kill){
Write-Host “Killing Process [$($p.Name)] for User [$user]”
if($whatif){
write-Host “What if: Performing operation “”kill”" on Target “”$($p.Name)”".”
}
}
else{
Write-Host “Killing Process $($p.Name)”
$p.Terminate() | out-null
}
return $true
}
}
if($kill){
if($whatif){
write-Host “What if: Performing operation “”kill”" on Target “”$($p.Name)”".”
}
else{
Write-Host “Killing Process $($p.Name)”
$p.Terminate() | out-Null
}
}
else{
Write-Host “$p.Name”
}
}
}
}
}
[/code]