LeoPonti Blog

Posts
• PowerTip: Use PowerShell to Get BitLocker Recovery Key

Use Windows PowerShell to get the BitLocker recovery key. ...( read more )...( read more )
• PowerTip: Use PowerShell to Rename Printers

Summary : Learn how to use Windows PowerShell 3.0 in Windows 8 to rename a printer. How can I use Windows PowerShell 3.0 in Windows 8 to rename a printer? Use the Get-Printer function to retrieve the printer, and pipe it to the Rename-Printer function...
• PowerTip: Use PowerShell to Write BitLocker Recovery Key to Text File

Summary : Use Windows PowerShell to write your BitLocker recovery key to a text file. If I forgot to save my BitLocker recovery key when I enabled BitLocker on my laptop, how can I use Windows PowerShell to write it to a text file so I can copy it to a USB key for safe keeping? From an elevated Windows PowerShell console, use the Get-BitLockerVolume function, select -MountPoint C , choose the KeyProtector and the RecoveryPassword properties, and then redirect the output to a text file: (Get-BitLockerVolume -MountPoint C).KeyProtector.recoverypassword > c:\bitlockerkey.txt...( read more )

• PowerShell Workflow for Mere Mortals: Part 5

Summary : Microsoft Scripting Guy, Ed Wilson, concludes his five-part series about Windows PowerShell Workflow. Hey, Scripting Guy! I have a number of commands that I want to run against several remote servers. The commands include stuff that must happen prior to something else happening. But then, there are also some things that I would like to happen as fast as possible. Is this permissible? If so, do I have to write two different workflows? —TB Hello TB, Microsoft Scripting Guy, Ed Wilson, is here. This afternoon I am sipping an awesome cup of Oolong tea with a cinnamon stick, jasmine flower, and lemon grass. The flavor is just about perfect. In the background, I am listening to Ravel . Outside, the sky is dark and it is raining. The thunder seems to punctuate the music. Note This is the last post in a five-part series about Windows PowerShell Workflow for “mere mortals.” Before you read this post, please read: PowerShell Workflow for Mere Mortals: Part 1 PowerShell Workflow for Mere Mortals: Part 2 PowerShell Workflow for Mere Mortals: Part 3 PowerShell Workflow for Mere Mortals: Part 4 For more information about workflow, see these Hey, Scripting Guy! Blog posts: Windows PowerShell Workflow . Well TB, the good news is that you do not need to write two different workflows to enable parallel processing and sequential processing. Windows PowerShell Workflows are flexible enough to handle both in the same workflow. Adding a sequence activity to a workflow To add a sequence activity to a Windows PowerShell Workflow, all I need to do is use the Sequence keyword and specify a script block. When I do this, it causes the commands in the sequence script block to run sequentially and in the specified order. The key concept here is that a Sequence activity occurs within a Parallel activity. The Sequence activity is required when I want commands to run in a particular order. This is because commands running inside a Parallel activity run in an undetermined order. The commands in the Sequence script block run in parallel with all of the commands in the Parallel activity. But the commands within the Sequence script block run in the order in which they appear in the script block. The following workflow illustrates this technique: workflow get-winfeatures { Parallel { Get-WindowsFeature -Name PowerShell* InlineScript {$env:COMPUTERNAME} Sequence { Get-date$PSVersionTable.PSVersion...
• Weekend Scripter: Understanding PowerShell in Windows 8

Summary : Microsoft Scripting Guy, Ed Wilson, talks about understanding Windows PowerShell 3.0 in Windows 8. Microsoft Scripting Guy, Ed Wilson, is here. It is an exciting and great day! I have been working a bit to solidify the editorial calendar for the Hey, Scripting Guy! Blog. I can say that there are some absolutely awesome posts coming up in the next couple months. I am not just saying this because I am writing them. Nope. I have a great lineup of guest writers. The upcoming stuff will simply rock! Windows 8 posh stuff… One of the really great things about Windows 8 is the implementation of Windows PowerShell 3.0. But many of the really cool commands (cmdlets or functions) are not strictly Windows PowerShell 3.0. For example, one function I use on a regular basis when I am traveling is Get-NetAdapter . This command tells me if a network adapter is up. Because I toggle my wireless and my Ethernet adapter connections (on or off depending on the network), I often need to see if a particular adapter is up. Another function I use a lot when I am traveling is the Get-NetConnectionProfile function. This tells me how a particular network adapter has been identified by the operating system. I can modify the profile by using Set-NetConnectionProfile . I need to use this a lot when I am traveling and I want to demonstrate Windows PowerShell. Neither of the two previously mentioned functions are part of Windows PowerShell 3.0, per se. They are included in modules that ship with Windows 8. The associated modules are shown here: PS C:\> Get-Command Get-NetConnectionProfile, Get-NetAdapter CommandType Name ModuleName ----------- ---- ---------- Function Get-NetConnectionProfile NetConnection Function Get-NetAdapter NetAdapter Am I being pedantic? If so, it is not my intention. It is important to know where specific functionality arises, so that when I install Windows PowerShell 3.0 onto a computer running Windows 7, I will know what to expect. This concept will be important when Windows 8.1 ships with Windows PowerShell 4.0 because Windows PowerShell 4.0 in Windows 8.1 will expose certain cmdlets and functions that may not be available if I install Windows PowerShell 4.0 on a down-level system. Emulating capability With all the great commands in Windows 8, it is easy to forget that the capability comes from modules that ship with the operating system, and that they are not part of Windows PowerShell 3.0 core installation...

• Weekend Scripter: Understanding PowerShell in Windows 7

Summary : Microsoft Scripting Guy, Ed Wilson, talks about understanding Windows PowerShell in Windows 7. Microsoft Scripting Guy, Ed Wilson, is here. This morning I am sipping a cup of English Breakfast tea, with goji berries , lemon grass, and cinnamon...

• PowerTip: Use PowerShell to Get DHCP Server Database Info

Summary : Learn how to use Windows PowerShell to get the DHCP Server database information. How can I use Windows PowerShell to get the database information for a DHCP server if I do not know the name of the server? Use the ServerName property from...
• Artículos "The Scripting Guys" semana 25/8 al 01/9

Hola a todos! En esta oportunidad. quiero dejarles la lista de artículos publicados en el Scripting Guy! Blog durante esta semana. Realmente es excelente el trabajo de Ed Wilson!. Weekend Scripter: Creating ACLs for Windows Azure Endpoints—Part 2 of 2 PowerTip: Use PowerShell to Parse Text Files Weekend Scripter: Creating ACLs for Windows Azure Endpoints—Part 1 of 2 PowerTip: Capture Console Application Data with PowerShell Automating DiskPart with Windows PowerShell: Part 5 PowerTip: List Physical Drives with PowerShell Changes to TechNet Library Scripting Node Automating DiskPart with Windows PowerShell: Part 4 PowerTip: Use PowerShell to Get a List of All Volumes Automating DiskPart with Windows PowerShell: Part 3 PowerTip: Show attached USB Drives with PowerShell Automating DiskPart with Windows PowerShell: Part 2 PowerTip: Use PowerShell to Automate Commands with DiskPart Automating DiskPart with Windows PowerShell: Part 1 PowerTip: Find PowerShell Events and Levels Weekend Scripter: Install Free PowerShell Remote Server Admin Tools PowerTip: Use PowerShell to Get BitLocker Recovery Key Espero disfruten de los artículos!! Excelente semana!! Saludos LeoPonti

• PowerTip: Use PowerShell to Create Hash Table

Summary : Use a Windows PowerShell cmdlet to create a hash table. How can I use Windows PowerShell to create a hash table if do not remember the special syntax? Use the ConvertFrom-StringData cmdlet, and put each key-value pair on its own line. (You can perform this on a single line by using backtick character plus n ( n ) for a new line): PS C:\> convertfrom-stringdata "a=1nb=2nc=3" Name Value ---- ----- c 3 a 1 b 2
• Redireccionando contenedor default de objetos Users en AD

Summary : Learn how to display all Windows PowerShell modules and cmdlet names. How can I get output that shows Windows PowerShell module names and the cmdlets or functions that are contained inside the modules? Use the Get-Module cmdlet, and then for each module, display the name and use Get-Command ( gcm is an alias) to retrieve the cmdlets and functions (this is a single-line command broken at the pipe character for readability): Get-Module -ListAvailable | foreach {"rnmodule name: $_"; "r`n";gcm -Module$_.name -CommandType cmdlet, function | select name}...( read more )
Summary : Use Windows PowerShell to create a report for a Windows failover cluster. Microsoft Scripting Guy, Ed Wilson, is here. Welcome back guest blogger, Rhys Campbell … I’m involved in the administration of several Failover Clusters , and I wanted to be able to easily report on these and get an alert for any changes in status. Enter Windows PowerShell. This Windows PowerShell script uses various FailoverCluster cmdlets to write information about a Windows Failover Cluster to a HTML file and copy this to a web server directory root. The script also tracks changes to the state of the cluster and sends an email notification with the details. The following steps outline the process to set up this script. 1. Open clstr.ps. We need to change the SMTP details here. Change the following line… sendEmail "smtp.domain.co.uk" 8025 $subject$report $transcript "to@domain.co.uk" "from@domain.co.uk"; –to– sendEmail "your.smtp.server" 25$subject $report$transcript "who.this.goes.to@domain.co.uk" "powershell@domain.co.uk"; Save and close the file. 2. Create a folder somewhere that is appropriate for the Windows PowerShell script and other resources, for example c:\tmp . This should be fully writable for the user who will execute the .ps1 file. Copy clstr.ps1 to the folder. Create a folder called Resources in the same directory and copy the style.css folder here (customize it if you desire). You may need to sign the script depending on your preferred execution policy. (For more information, see Using the Set-ExecutionPolicy Cmdlet .) 3. Now we are ready to test the execution of the script. The script is executed with three parameters inside a Windows PowerShell console: C:\tmp\clstr.ps1 <cluster name> c:\tmp\ c:\path\to\web\server\root\ Note The cluster name refers to the Windows Failover Cluster name, not the SQL instance name. Parameter 2 should be the script directory root. Parameter 3 should be the root of your web server HTML directory. Notice the trailing slashes. If you execute this a couple of times, the script root folder should look something like this: The script uses the text file to keep track of the cluster state and what has changed. If you have multiple clusters, you can set this up for each one. In this situation, I recommend setting up a directory structure similar to this: C:\tmp\ClusterName1 C:\tmp\ClusterName2 and so on... 4. After your setup...