What Can I Do With Windows PowerShell?
Windows PowerShell Tips
Scripting with Windows PowerShell
MSDN Virtual Lab: Creating Windows PowerShell V2 Script Cmdlets -now advanced functions
TechNet Virtual Lab: Introduction to Windows PowerShell
Wednesday, December 24, 2008
ad groups -duplicate ad group structure in testdom
ADSearch Group Property Attributes:
How to enumerate active directory groups using .Net Directory Services
Scripts to manage Active Directory Groups
get groups that are members of other groups
Set objGroup = GetObject _
("LDAP://CN=Finance Department,OU=Finance,DC=fabrikam,DC=com")
For Each strUser in objGroup.Member
Set objMember = GetObject("LDAP://" & strUser)
If objMember.Class <> "group" Then
objGroup.Remove(objMember.ADsPath)
End If
Next
Set objGroup = GetObject _
("LDAP://cn=Finance Managers, ou=Finance, dc=fabrikam, dc=com")
For Each strUser on objGroup.Member
Set objMember = GetObject("LDAP://" & strUser)
Wscript.Echo objMember.CN & ", " & objMember.Class
Next
Set objGroup = GetObject _
("LDAP://cn=Finance Managers, ou=Finance, dc=Fabrikam, dc=com")
Select Case objGroup.GroupType
Case 2
Wscript.Echo "This is a global distribution group."
Case 4
Wscript.Echo "This is a domain local distribution group."
Case 8
Wscript.Echo "This is a universal distribution group."
Case -2147483646
Wscript.Echo "This is a global security group."
Case -2147483644
Wscript.Echo "This is a domain local security group."
Case -2147483640
Wscript.Echo "This is a universal security group."
End Select
ctp3
get it here
?s
Discussions in microsoft.public.windows.powershell
changes
Changes of particular interest
PowerShell 2.0 CTP3 has arrived!
Download WinRM 2.0 CTP3 (required for PowerShell remoting)
?s
Discussions in microsoft.public.windows.powershell
changes
Changes of particular interest
PowerShell 2.0 CTP3 has arrived!
Monday, December 22, 2008
Effective PowerShell from http://keithhill.spaces.live.com/
Effective PowerShell Item 1: The Four Cmdlets That are the Keys to Finding Your Way Around PowerShell, Effective PowerShell,
Effective PowerShell Item 2: Use the Objects Luke. Use the Objects
Effective PowerShell Item 3: Know Your Output Formatters
Effective PowerShell Item 4: Commenting Out Lines in a Script File
Effective PowerShell Item 6: Know What Objects Are Flowing Down .the pipe
Effective PowerShell Item 7: Understanding "Output"
Effective PowerShell Item 8: Output Cardinality - Scalars .
Effective PowerShell Item 9: Regular Expressions
Effective PowerShell Item 10: Understanding PowerShell Parsing
Simple and effective PowerShell scripts for Exchange
Simple and effective PowerShell scripts for Exchange
The first one is the one-liner he wrote to help him out of the "Incredible Growing Logs" problem, which lists out the users connected to a particular mailbox store and which client they're using (Outlook versions or HTTP for OWA)
A one line script which checks the free disk space on every logical local drive on every computer in a specific OU:
The PowerShell that they use the most at the university is this script, which returns some mailbox details, including SMTP addresses, quota and usage for a user on Exchange 2003 or 2007:
The last Exchange-related PowerShell stuff is entitled "How much space are orphaned mailboxes taking up on my Exchange servers?" and does what it says on the tin.
The first one is the one-liner he wrote to help him out of the "Incredible Growing Logs" problem, which lists out the users connected to a particular mailbox store and which client they're using (Outlook versions or HTTP for OWA)
A one line script which checks the free disk space on every logical local drive on every computer in a specific OU:
The PowerShell that they use the most at the university is this script, which returns some mailbox details, including SMTP addresses, quota and usage for a user on Exchange 2003 or 2007:
The last Exchange-related PowerShell stuff is entitled "How much space are orphaned mailboxes taking up on my Exchange servers?" and does what it says on the tin.
array compare
This article was Previously posted on Ying Li'
===
$arrFirst = get-content First.txt
$arrSecond = get-content Second.txt
New-Item "C:\Myworkplace\ps\FirstInSecond.txt" -Type file
New-Item "C:\Myworkplace\ps\FirstNotInSecond" -Type file
Foreach ($First in $arrFirst)
{
If ($arrSecond -contains $First)
{Add-content "C:\Myworkplace\ps\FirstInsecond.txt" $First}
Else
{Add-content "C:\Myworkplace\ps\FirstNotInSecond.txt" $First}
===
PS> $a1 = 1,1,2
PS> $a2 = 1,2,1
You could force "sequence equality" by setting SyncWindow to 0:
Compare-Object $a1 $a2 -SyncWindow 0
f5 powershell bigIP
F5 has integrated the BIG-IP system with Microsoft PowerShell using the iControl API/SDK. The iControl PowerShell Cmdlets and scripts make use of the iControl .NET Assembly available from F5, and can be used to manage F5 devices
Saturday, December 20, 2008
ws-management - posh remoting
Enabling WS-Management through Group Policy
Installation and Configuration for Windows Remote Management
about_remote_faq
Out of the box; Vista WS-Man e xposes WMI information as well as Windows Remote Shell capabilities. What this means is that with WS-Man it's much easier to get instrumentation from remote machines as well as use that info in scripts.
Installation and Configuration for Windows Remote Management
Configuring WS-Management about_remote_requirements |
Out of the box; Vista WS-Man e xposes WMI information as well as Windows Remote Shell capabilities. What this means is that with WS-Man it's much easier to get instrumentation from remote machines as well as use that info in scripts.
Friday, December 19, 2008
Monday, December 15, 2008
snap-ins
To determine which snap-ins you can add to the standard Windows PowerShell console, type the following command at the command prompt:
Get-PSSnapin -Registered
to add a snap-in
add-pssnapin [-name]
To see the installed snapins use
Get-PSSnapin
Removes Windows PowerShell snap-ins from the current console.
Remove-PSSnapIn [-name]
Get-PSSnapin -Registered
to add a snap-in
add-pssnapin [-name]
To see the installed snapins use
Get-PSSnapin
Removes Windows PowerShell snap-ins from the current console.
Remove-PSSnapIn [-name]
Saturday, December 13, 2008
SCRIPT CMDLETS now advanced functions
Everyone needs to get good with Advanced Functions
Under The Stairs: Parameter Attributes in PowerShell V2 CTP ...
Advanced Functions Support -confirm
A guide to PowerShell’s Advanced Functions
Advanced Functions with Powershell –Having some Fun
"CmdletBinding()]" google search add advanced function
Richard Siddaway's Blog
posh team blog advanced function search
Under The Stairs: Parameter Attributes in PowerShell V2 CTP ...
There is quite a lot to advanced functions so I am going to take a few posts to explore them fully
A Module to Create Modules and Advanced Functions
WINDOWS POWERSHELL 2.0 FEATURE FOCUS - SCRIPT CMDLETS
PowerShell 2.0 CTP - Script Cmdlets
MSDN Virtual Lab: Creating Windows PowerShell V2 Script Cmdlets
Powershell has a way to generate script cmdlets from an existing cmdlet.
turn some of these » Windows PowerShell » Windows PowerShell Script Repository into SCRIPT CMDLETS
Under The Stairs: Parameter Attributes in PowerShell V2 CTP ...
Advanced Functions Support -confirm
A guide to PowerShell’s Advanced Functions
Advanced Functions with Powershell –Having some Fun
"CmdletBinding()]" google search add advanced function
Richard Siddaway's Blog
posh team blog advanced function search
Under The Stairs: Parameter Attributes in PowerShell V2 CTP ...
There is quite a lot to advanced functions so I am going to take a few posts to explore them fully
A Module to Create Modules and Advanced Functions
WINDOWS POWERSHELL 2.0 FEATURE FOCUS - SCRIPT CMDLETS
PowerShell 2.0 CTP - Script Cmdlets
MSDN Virtual Lab: Creating Windows PowerShell V2 Script Cmdlets
Powershell has a way to generate script cmdlets from an existing cmdlet.
turn some of these » Windows PowerShell » Windows PowerShell Script Repository into SCRIPT CMDLETS
Saturday, December 6, 2008
PowerShellASP
From their site:
PowerShellASP is an ASP-like template language for Web Applications; templates contain a mixture of markup (HTML, XML or whatever you want to generate) and inline PowerShell code. At runtime, templates/pages are fully translated to PowerShell code and executed as a single unit inside a PowerShell pipeline, with the results sent to the client browser.
PowerShellASP runs off the ASP.NET platform, implemented as a custom IHttpHandler mapped to *.ps1x files. Because of this, you can mix PowerShellASP pages alongside any ASP.NET application. This provides a great way to leverage PowerShellASP inside your existing applications as needed or you can create complete applications from scratch based only on *.ps1x pages.
map ad
Get-ADMapObject
Map Active Directory objects using the Show-NetMap script
needs
Microsoft Research .NetMap and PowerShell
Map Active Directory objects using the Show-NetMap script
needs
Microsoft Research .NetMap and PowerShell
using posh to get-sqldata
Accessing SQL Server Data from PowerShell, Part 1
Accessing SQL Server Data from PowerShell, Part 2 Use ADO.NET to insert, update, and delete data
Parse SQL DataSet to variables in Windows Powershell - scrool 2 end
Getting Powershell output into a sql table in Windows Powershell
PowerShell Mini SQL Query Analyzer
how to connect to a SQL database, query the Employees table of the Northwind database, and write those results to the screen.
Using Powershell to Generate Table-Creation Scripts
Create Your First SQL Server Database in 3 Quick Steps
Accessing SQL Server Data from PowerShell, Part 1
SQL Server PowerShell Overview
get-data from sql start-sql
Quick and Dirty Software Inventory with PsInfo and PowerShell
executing SQL queries from Powershell in Windows Powershell
Check your SQL Server using Windows PowerShell –series
If you install the SQL Server 2008 client software, you get a SQL Server
PowerShell snap-in. You can run the sqlps.exe utility that loads the snapin
into a PowerShell environment, or start PowerShell and load in the snap-in
yourself. With the snap-in, you can get a list of the instances on a
computer by:
cd SQLSERVER:\SQL\MyComputerName
dir
Running SQL Server PowerShell:
http://msdn.microsoft.com/en-us/library/cc281954.aspx
Using the SQL Server PowerShell Provider:
http://msdn.microsoft.com/en-us/library/cc281947.aspx
NOTE: the Running SQL Server PowerShell topic still uses the old names for
the snap-in. The next update to Books Online includes an update to the topic
that uses the released names: SqlServerProviderSnapin100 and
SqlServerCmdletSnapin100.
--
poshOUT-2-sqlIN
parse results - scroll 2 end
Accessing SQL Server Data from PowerShell, Part 2 Use ADO.NET to insert, update, and delete data
Parse SQL DataSet to variables in Windows Powershell - scrool 2 end
Getting Powershell output into a sql table in Windows Powershell
PowerShell Mini SQL Query Analyzer
how to connect to a SQL database, query the Employees table of the Northwind database, and write those results to the screen.
Using Powershell to Generate Table-Creation Scripts
Create Your First SQL Server Database in 3 Quick Steps
Accessing SQL Server Data from PowerShell, Part 1
SQL Server PowerShell Overview
get-data from sql start-sql
Quick and Dirty Software Inventory with PsInfo and PowerShell
executing SQL queries from Powershell in Windows Powershell
Check your SQL Server using Windows PowerShell –series
If you install the SQL Server 2008 client software, you get a SQL Server
PowerShell snap-in. You can run the sqlps.exe utility that loads the snapin
into a PowerShell environment, or start PowerShell and load in the snap-in
yourself. With the snap-in, you can get a list of the instances on a
computer by:
cd SQLSERVER:\SQL\MyComputerName
dir
Running SQL Server PowerShell:
http://msdn.microsoft.com/en-us/library/cc281954.aspx
Using the SQL Server PowerShell Provider:
http://msdn.microsoft.com/en-us/library/cc281947.aspx
NOTE: the Running SQL Server PowerShell topic still uses the old names for
the snap-in. The next update to Books Online includes an update to the topic
that uses the released names: SqlServerProviderSnapin100 and
SqlServerCmdletSnapin100.
--
poshOUT-2-sqlIN
parse results - scroll 2 end
sharepoint&posh
SharePoint and PowerShell Demo - Part 1
SharePoint and PowerShell Demo - Part 2
Karine Bosch > posh & sharepoint entries
Powershell to control SharePoint
Taming SharePoint -powerGUI
Manipulating remote SharePoint Lists with PowerShell
PowerShell & the SharePoint object model
SharePoint and PowerShell - practical tips
Presention Slides and PowerShell code from UK SharePoint User Group Thursday 26'th October
PowerShell for Flexible Iterative SharePoint-based Development
articles on setting up a sharepoint dev environment:
Using Tools to make SharePoint Development Easier
Powershell + SharePoint
Automating Common SharePoint Tasks with PowerShell
SharePoint and PowerShell Demo - Part 2
Karine Bosch > posh & sharepoint entries
Powershell to control SharePoint
Taming SharePoint -powerGUI
Manipulating remote SharePoint Lists with PowerShell
PowerShell & the SharePoint object model
SharePoint and PowerShell - practical tips
Presention Slides and PowerShell code from UK SharePoint User Group Thursday 26'th October
PowerShell for Flexible Iterative SharePoint-based Development
articles on setting up a sharepoint dev environment:
Using Tools to make SharePoint Development Easier
Powershell + SharePoint
Automating Common SharePoint Tasks with PowerShell
Wednesday, December 3, 2008
profile load issue solved
File C:\Users\Gaurav\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.
At line:1 char:2
+ . <<<< ‘C:\Users\Gaurav\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1′
At line:1 char:2
+ . <<<< ‘C:\Users\Gaurav\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1′
This is because PowerShell does not allow the execution of scripts by default. To fix this open PowerShell in Admin mode and set the execution policy to unrestricted by running the following command:
Add-PSSnapin Quest.ActiveRoles.ADManagementSet-ExecutionPolicy remotesigned
Notepad $profile
Set-ExecutionPolicy remotesigned
Sunday, November 30, 2008
Saturday, November 22, 2008
error handeling
Trap [Exception] { “In PowerShell”
Default Error Handling
Error handling in PowerShell scripts
Lunch Lesson: Error Handling in PowerShell
Methods for handling errors in PowerShell can range from simple to complex
Catch-Error.ps1
#Requires -Version 2 # Show-TryCatchFinally.ps1 # Demonstrates try/catch/finally in V2 # First, try something that will work Try { $I=1 } Catch {"Caught a problem in try 1" } Finally { "All done with 1st try" } # Now try something that fails $one=1 #$zero=0 Try { $one/$zero} Catch {"Caught a problem in try 2"}
Default Error Handling
Error handling in PowerShell scripts
Lunch Lesson: Error Handling in PowerShell
Methods for handling errors in PowerShell can range from simple to complex
for each
In PowerShell, foreach is both a statement and an alias to the ForEach-Object cmdlet.
While you might think that both of these examples do exactly the same thing, they do not.
Powershell tutorial 8 part 1
PowerShell tutorial 8 part 2
Essential PowerShell: Understanding foreach
Friday, November 21, 2008
Wednesday, November 12, 2008
Powershell and the VI Toolkit!
new, 12-19-08 PowerGUI VMware PowerPack has lots of great features, including the ability to manage your ESX Hosts and VMs, as well as doing bulk operations. In my opinion, PowerGUI's best feature is that as you interact with PowerGUI, it generates PowerShell code as you go. You can take this code and re-run it later or you can parameterize it and turn it into a script. This is especially great if you're not a hard-core scripter, or if you aren't very familiar with PowerShell.
VMware in PowerGUI
Powershell and the VI Toolkit! plus
Project Description
The VI Toolkit for Windows Community Extensions is a PowerShell module designed to work with the VI Toolkit for Windows (http://vmware.com/go/powershell).
Project Goals
This project aims to help make managing VMware products with PowerShell easy and really powerful. Our current VI Toolkit for Windows contains 125 cmdlets that makes life a lot easier for people who manage VMware ESX and VMware VirtualCenter. With this project we plan to build on that by providing libraries of really useful stuff based on the ideas we see in our VMware Community as well as plenty of ideas of our own
For script nodes to work you would need to either:
Quick VI Toolkit One-liners
Setting of advanced options with the VI Toolkit
Track Datastore Free Space
VMware Stats Oneliner
How many VMs in each LAN?
VMware Server info
Changing your VMware license server
top-twenty volumes on your virtual servers with the least free disk space
Some advice on creating Powershell scripts
Some Advice on Creating Powershell Scripts (Part 2)
VMware in PowerGUI
Powershell and the VI Toolkit! plus
Project Description
The VI Toolkit for Windows Community Extensions is a PowerShell module designed to work with the VI Toolkit for Windows (http://vmware.com/go/powershell).
Project Goals
This project aims to help make managing VMware products with PowerShell easy and really powerful. Our current VI Toolkit for Windows contains 125 cmdlets that makes life a lot easier for people who manage VMware ESX and VMware VirtualCenter. With this project we plan to build on that by providing libraries of really useful stuff based on the ideas we see in our VMware Community as well as plenty of ideas of our own
For script nodes to work you would need to either:
- start PowerGUI as VI Client plugin, or
- add Connect-VI-Server to your PowerShell profile, or
- add the -Server $global:VIServer to your scripts.
Quick VI Toolkit One-liners
Setting of advanced options with the VI Toolkit
Track Datastore Free Space
VMware Stats Oneliner
How many VMs in each LAN?
VMware Server info
Changing your VMware license server
top-twenty volumes on your virtual servers with the least free disk space
Some advice on creating Powershell scripts
Some Advice on Creating Powershell Scripts (Part 2)
PowerShell cmdlets for AD
PowerShell cmdlets for AD
Andrei published on PowerGUI.org a bunch of how-to’s to Active Directory management with PowerShell:
How can you set any arbitrary AD attribute with PowerShell
Andrei published on PowerGUI.org a bunch of how-to’s to Active Directory management with PowerShell:
How can you set any arbitrary AD attribute with PowerShell
Creating a PowerShell GUI with PrimalForms
Saturday, October 18, 2008
Monday, October 13, 2008
Tuesday, July 1, 2008
database info
PowerShell and ADO.NET
PowerShell Mini SQL Query Analyzer
Comparing Python and PowerShell DBA Scr
How Can I Use Windows PowerShell to Pull Records From a Microsoft Access Database?
Managing SQL Server using PowerSMO
PowerSMO At Work Part I: DBA Scripts and Functio
db 2 html
PowerSMO at Work Part 2
how to connect to a SQL database, query the Employees table of the Northwind database
Using PowerShell and SQL Server Together
Implementing Real-World Data Input Validation using Regular Expressions
PowerShell Mini SQL Query Analyzer
Comparing Python and PowerShell DBA Scr
How Can I Use Windows PowerShell to Pull Records From a Microsoft Access Database?
Managing SQL Server using PowerSMO
PowerSMO At Work Part I: DBA Scripts and Functio
db 2 html
PowerSMO at Work Part 2
how to connect to a SQL database, query the Employees table of the Northwind database
Using PowerShell and SQL Server Together
Implementing Real-World Data Input Validation using Regular Expressions
Subscribe to:
Posts (Atom)