background preloader

Powershell

Facebook Twitter

Windows PowerShell Survival Guide - TechNet Articles - Home - TechNet Wiki. This article was formerly titled "Automating IT Tasks with Windows PowerShell Overview.

Windows PowerShell Survival Guide - TechNet Articles - Home - TechNet Wiki

"** Introduction and Getting Started PowerShell is a vast product, especially when you take into account how it's used in other products such as Lync Server, Exchange, and the Windows Operating System. Powershell - PowerShell Cmdlet and Help Designer. Windows PowerShell: Sharing Your Scripts - Made Easy. One limitation of Windows PowerShell v1 is that it didn’t do much to make script sharing easier.

Windows PowerShell: Sharing Your Scripts - Made Easy

Sure, you could easily copy a .ps1 script file to another computer, or even zip it up and e-mail it to a colleague, but you could do that with VBScript more than a decade ago. If your script included reusable functions, however, whoever received it from you would have to know how to dot-source it, or would wind up actually having to modify it in order to execute those functions. All in all, it was an acceptable situation—even if it wasn’t ideal. The situation became less acceptable for scripts that were accompanied by custom format views or type extensions, because those additional files had to be manually loaded into the shell in order to be used by the script. Windows PoweShell: Make a Command into a Reusable Tool.

You can repackage and reuse your efforts when it comes to Windows PowerShell commands and cmdlets.

Windows PoweShell: Make a Command into a Reusable Tool

No matter how inexperienced you are with Windows PowerShell when you first start working with it, there’s always plenty of room for growth. You can start out running simple commands, work up to more-complicated commands, and eventually repackage those commands into something that looks and feels almost like a native cmdlet. These are called advanced functions, and are informally known as “script cmdlets.” Windows PoweShell: Think Commands, Not Scripts. Windows PowerShell: Splatting. Bundling parameters before sending them along to a command can save you time, but only if you’re using the latest version of Windows PowerShell.

Windows PowerShell: Splatting

Where else but in the IT industry could you use a word like “splatting” in a serious, professional context? Windshield repair, perhaps, but not many other places. Overview of Migration Cmdlets. Windows Server Migration Tools includes five Windows PowerShell cmdlets that let you migrate some server roles, features, operating system settings, shares, and other data from computers that are running Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, or Windows Server® 2008 R2, or to computers that are running Windows Server 2008 R2.

Overview of Migration Cmdlets

This topic identifies and describes the Windows PowerShell cmdlets that are part of Windows Server Migration Tools. For a complete list of operating systems that are supported by Windows Server Migration Tools, see Windows Server Migration Tools and Guides in this Help. Automate Active Directory Migration Tool using Windows PowerShell « blog.powershell.no. Active Directory Migration Tool (ADMT) provides the ability to restructure Active Directory domain structures.

Automate Active Directory Migration Tool using Windows PowerShell « blog.powershell.no

It allows you to migrate users, groups and computers between domains, both intra-forest and inter-forest. Features includes password migration, SID migration and security translation among several others. ADMT was recently released in version 3.2, adding support for Windows Server 2008 R2 and Managed Service Accounts. You can find the download here, and the ADMT migration guide here. ADMT provides three options on how to use it, where the first and maybe most used is the GUI: What's New in Active Directory Domain Services (AD DS) in Windows Server 2008 R2: Active Directory PowerShell. PowerShell Community Extensions.

PowerShell Integration The goal is to provide the PSCX user with a snapin that looks and feels like PowerShell cmdlets.

PowerShell Community Extensions

We also want to avoid polluting the user's environment with unnecessary temp variables. Variables Try to limit the number of global scope variables that you create. In fact, the only global variable created by PowerShell should be $Pscx. Indented! » Blog Archive » Listing all domains in a forest. Indented! » Blog Archive » Microsoft DNS & static records. Windows 2008 has an improved user interface for DNS.

Indented! » Blog Archive » Microsoft DNS & static records

The main console includes details of a records time stamp and whether or not the record is Static. Life isn’t quite so easy with Windows 2003. However, as each static record has a time stamp set to 0 they can be found with a little work. When using an Active Directory Integrated zone records are stored within Active Directory as dnsNode objects.

The Time Stamp value is encoded along with the rest of the record properties (TTL, etc) in the dnsRecord attribute on the dnsNode. The DNS management console To see the current time stamp, and whether a record is dynamic or not first enable View / Advanced in the DNS console. The record below is dynamic, if the box is not ticked, and the time stamp field is blank the record is static. Indented! » Blog Archive » Microsoft DNS & stale records. This post explains how to identify and report on stale records in a dynamically updated Microsoft DNS zone.

Indented! » Blog Archive » Microsoft DNS & stale records

The time stamp taken from a DNS record represents the numbers of hours since 01/01/1601 00:00. The value can be converted into a useful date within a script. By default, all times are reported and tested in UTC. Indented! » Blog Archive » NTFS, PowerShell, Get-ACL & listing explicit rights. A short script to list explicit rights assigned to a directory structure.

Indented! » Blog Archive » NTFS, PowerShell, Get-ACL & listing explicit rights

It uses the recursive option of ls (an Alias for Get-ChildItem) to drop down through the directory structure. There are lots of little programs around that can do exactly the same thing, probably quite a few more efficiently than this. The match is not case sensitive. If the value for $SecurityPrincipal is left blank the script will return all explicitly assigned rights. # Uses match, either a specific user / group or blank for all explicit rights $SecurityPrincipal = "chris" # The starting point $BasePath = "C:" # An array to hold the data returned $ExplicitRights = @() ForEach ($DirEntry in (Get-ChildItem $BasePath -Recurse)) { # Add an entry to the report where it matches the criteria set in the ?

Indented! » Blog Archive » Modifying DNS records with WMI. The examples below show modification of Host or A records, but it is possible to extend the example to use any of the types above. Using VbScript to modify records This example demonstrates the use of WMI in VbScript to modify a record. The first value for Modify is the TTL, by using objItem.TTL we just reinsert the existing value, only changing the IP address. ' Connect to the WMI Service Set objWMIService = GetObject("winmgmts:\\dns01\root\MicrosoftDNS") ' Run a query to get the record we want to change Set colItems = objWMIService.ExecQuery("SELECT * FROM MicrosoftDNS_AType" & _ " WHERE ContainerName='domain.example' AND OwnerName='test.domain.example', , 48) ' Loop through the results For Each objItem in colItems ' Modify the record objItem.Modify objItem.TTL, "1.2.3.4" Next.

Indented! » Blog Archive » Administering Microsoft DNS in PowerShell. I have released a PowerShell 2.0 module using the WMI provider here. There are a few limitations of the interface. The properties associated with Aging are read-only and cannot be set. Several of the configuration options are not available including the option to enable GlobalNames with Windows Server 2008. Common variables The examples below use two common variables. BITS file transfer PowerGUI PowerPack. What is this? The usual Windows way of copying files does not provide any resume option if the file transfer gets interrupted for some reason. Similarly, some of the web downloads such as SharePoint 2010 or any large file downloads from Microsoft download site, etc use the HTTP download process and hence do not have any resume option unless you use a download manager software. By default, BITS transfers files in the background, unlike other protocols that transfer files in the foreground. Background transfers use only idle network bandwidth in order to preserve the user’s interactive experience with other network applications, such as Internet Explorer.

PowerShell Scriptomatic. Have you ever found yourself thinking, “I wonder when the Scripting Guys are going to write a PowerShell Scriptomatic”? Fix WMI - ScriptIT. Great PowerShell resource to watch « IgorShare Weblog.

Tools

Scripts. Shells. Learning. Modules. Providers. Welcome to Debug Analyzer.NET !