Dave Horner's Website - Yet another perspective on things...
Home Tech Talk Windows OS Powershell - .NET control and automation.
196 guests
Rough Hits : 2924362
moon and stars
how did u find my site?

consciousness survives death of brain?

"Consistency is the last refuge of the unimaginative." -- Oscar Wilde
$$\cos x = \sum\limits_{n = 0}^\infty {\frac{{\left( { - 1} \right)^n x^{2n} }}{{\left( {2n} \right)!}}}$$

Powershell - .NET control and automation.

Sunday, 10 February 2008 15:51
I'm not yet sure what I think about Powershell. There are some things that are cool in it. I also love that it allows scripting of .NET objects....

I guess time will tell if I end up using it for tasks...or just use IronPython / C#.

#Powershell IRC chat on freenode

Scripting with Windows PowerShell
Running Windows PowerShell Scripts
PowerGUI - Administrative Powershell Console :
Download details: Windows PowerShell 1.0 Installation Package for Windows Vista x64 Edition (KB928439)
Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0)

Powershell ExecutionPolicy

Out of the box, you get Restricted, yup, no running .ps1 files from the cmd line.
It's like the first thing you have to bump your knee on when developing in powershell.
Set-ExecutionPolicy Unrestricted
Invoking a PowerShell script from cmd.exe (or Start | Run) | Poshoholic
java - How to run PowerShell script even if Set-ExecutionPolicy is banned? - Stack Overflow
Oh, and then you can always bypass the execution policy from the command line.
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File <script_name>

5 key commands for powershell


get-command | out-gridview
measure-command { read-host "press any key" }

pipe to Out-Null to send things to /dev/null

PowerShell Tip: Out-Null is to PowerShell What Duct Tape is to Mouth

PowerShell PowerBoots - PowerBoots makes it easier for scripters to create graphical user interfaces in PowerShell, exposing much of the power of WPF to PowerShell in a simple syntax which supports events, threading, and much, much, more.
Poshoholic - Totally addicted to PowerShell
Scripting with Windows PowerShell - MSDN Script Center
Windows PowerShell Blog
PowerShell Community Extensions - Home
O'Reilly Media | Windows PowerShell Cookbook
Windows PowerShell Cookbook - Hosted By Pavleck.NET
Windows PowerShell : Hosting PowerShell in a GUI â?? the Movie
Manning: Windows PowerShell in Action
PowerShell Basics
This e-mail address is being protected from spambots. You need JavaScript enabled to view it - Shell Tools Support for Powershell Analyzer and Powershell Plus
SDM Software Group Policy Freeware - checkout SDM GPMC PowerShell Cmdlets.
Pash - open source implementation of powershell.
Redmond | Column: First Look: WinRM & WinRS
Windows PowerShell : WINRM
Script everything with PowerShell and IronRuby « IronRuby rocks
PoshConsole - PoshConsole is a modern graphical PowerShell Console. We aim to have a complete open source implementation of the PSHostUserInterface and PSRawHostUserInterface written in WPF and including a custom ConsoleControl which can be reused for other purposes.
Show-UI: The PowerShell WPF Toolkit - Show-UI is the merger of PowerBoots and WPK, and it makes it easier for scripters to create graphical user interfaces in PowerShell, exposing much of the power of WPF to PowerShell in a simple syntax which supports events, threading, and much, much, more.

find which process locks a file using powershell

Easily Unblock All Files in a Directory Using PowerShell - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs
Use PowerShell to find out which process locks a file | beam us up scotty
Get-Process | foreach{$processVar = $_;$_.Modules | foreach{if($_.FileName -eq $lockedFile){$processVar.Name + " PID:" + $processVar.id}}}

PowerShell Workflow for Mere Mortals: Part 1 - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs 2 3 4 5

Hosting powershell from other languages

Asynchronously Execute PowerShell Scripts from C# - CodeProject

Powershell and registry

Powershell access is better than regedit. Learn your tools.
# get the value of the LSA keys
Get-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa
# Set value of the LSA key - disable the loopback check
New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -value "1" -PropertyType dword
Use PowerShell to Enumerate Registry Property Values - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs
Working with Registry Entries - using powershell of course.

Powershell and active directory

@Henning » Sample Domain Data - using powershell import-csv,set-content,foreach,get-random,add-content, and Free First-name and Last-name Databases (CSV and SQL) | The Quiet Affiliate to create sample data for mass sample user creation in AD.
param([string]$FileName, [string]$adpath)
Import-Module ActiveDirectory
function Import-Users([string]$UserFile)
    Import-Csv $UserFile | foreach-object {
        $accountName = $_.Lastname+$_.Firstname.Substring(0,2)
        $displayName=$_.Firstname+" "+$_.LastName
        New-AdUser $accountName -samAccountName $accountName -Company "Acme Corp." -Department $_.Department -DisplayName $displayName -GivenName $_.Firstname -Surname $_.Lastname -OfficePhone $_.Phone -Title $_.Position -CannotChangePassword $true -PasswordNeverExpires $true -Enabled $true -AccountPassword (ConvertTo-SecureString -AsPlainText "demo" -Force) -Path $spou
$spou = "OU=Acme,$adpath"
Import-Users $FileName
@Henning » Mass-Updating Active Directory
@Henning » Creating local users – en mass
$ComputerName = $env:COMPUTERNAME
$Computer = [adsi]"WinNT://$ComputerName"
function Add-User([string]$UserName, [string]$FullName, [string]$Description, [string]$Password)
    $User = $Computer.Create("user", $UserName)
    $User.Put("fullName", $FullName)
    $User.Put("description", $Description)
function Import-Users([string]$UserFile)
    Import-Csv $UserFile | foreach-object { Add-User $_.UserName $_.FullName $_.Description $_.Password }

Powershell and SQL

kwblog: Powershell Listing SQL Table Columns - sqlps

Powershell Base64

Under The Stairs: Working with Base64 Strings in PowerShell - extend System.String using powershell Update-TypeData to get FromBase64String and ToBase64String.

use powershell to enable remote desktop on remote machine

$remoteComputerName = "my_remote_computer"
# Connect to another computer and start the remote registry service 
( Get-WmiObject -computername $remoteComputerName Win32_Service -filter "Name='RemoteRegistry'").startservice()
( Get-WmiObject -computername $remoteComputerName Win32_Service -filter "Name='RemoteAccess'").ChangeStartMode('Manual') 
( Get-WmiObject -computername $remoteComputerName Win32_Service -filter "Name='RemoteAccess'").startservice()

use powershell to find zombie process || find and kill running process with commandline arguments

I like to use powershell to kill zombies. say for instance you have a script that you know runs all the time and locks or becomes unresponsive. using taskmgr is not very programmer of you. try using powershell to quickly find that troublesome process and terminate.
Get-WmiObject Win32_Process -Filter "name = 'perl.exe'" | where {$_.CommandLine -eq '"C:\strawberry\perl\bin\perl.exe" t/Server_PreFork.t'} | ForEach-Object { Invoke-WmiMethod -Path $_.__Path –Name Terminate }

windows 7 - How do I find out command line arguments of a running program? - Super User

WinRM tips

? DEVOPS + Chef + Windows at Ancestry.com - YouTube
Enable-WSManCredSSP -Role server -force
Set-Item 'WSMAN:\localhost\service\auth\credssp' -Value $true
Set-Item 'WSMAN:\localhost\Client\TrustedHosts' * -force
Set-Item 'WSMAN:\localhost\Shell\MaxMemoryPerShellMB' 2048
Set-Item 'WSMAN:\localhost\MaxTimeoutms' 1800000
invoke-command -computername $svr -Credential $cred -scriptblock $rsb

JamesKovacs/psake - psake - A build automation tool... now with less XML... syntax inspired by rake (aka make in Ruby) and bake (aka make in Boo) creating a graph of dependent tasks and executing them in the correct order.
Build Automation with PowerShell and Psake

quick what's my ip using powershell?

powershell (gwmi win32_NetworkAdapterConfiguration -Filter 'ipenabled = "true"').ipaddress[0]
#quick what's my default gateway using powershell?
powershell (gwmi win32_NetworkAdapterConfiguration -Filter 'ipenabled = "true"').defaultipgateway

Adam Driscoll's Blog github:adamdriscoll (Adam Driscoll)
adamdriscoll/PoshInternals: A pure script-based PowerShell module that provides deep system analysis and configuration.

file text replacement using powershell

(Get-Content file.sql).replace('REPLACETEXT', 'VALUE') | Set-Content file.sql
Last Updated on Wednesday, 24 May 2017 14:49