LeoPonti Blog

  • Windows Server 2012 - Generando Disco USB Booteable

    Hola a todos! En esta oportunidad, quiero compartir con ustedes una forma sencilla de hacer un dispositivo USB booteable con Windows Server 2012, de esta misma forma, también se puede hacer con Windows Server 2008R2, Windows 7 y Windows 8.-...
  • Add User Principal Names in Active Directory via PowerShell

    Summary : Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell to add user principal names to users in Active Directory. Hey, Scripting Guy! We are planning for our Active Directory migration, and as part of that, I am reviewing users. The problem is that I found out that whoever set up our original installation did not assign values for user principal names (UPN). This will cause us a problem as we move to a federated environment. Can you offer an easy way to populate this value? —CG Hello CG, Microsoft Scripting Guy, Ed Wilson, is here. This morning I am sitting on our lanai and checking my scripter@microsoft.com email on my Microsoft Surface RT. I received an email from one of my friends in Hawaii. He was telling me about a Hukilau he went to over the weekend. From his description, it makes me want to grab the Scripting Wife and head out west on the next available flight. The big problem right now, is the weather. I prefer August in Australia to August in Hawaii—it is really hot there. In Active Directory Users and Computers, the UPN shows up as the user logon name. It displays the UPN in two different fields, as shown in the following image. To find the actual Active Directory attribute name, I add a bunch of AAAs to the user logon name, and select a domain from the drop-down list. I then go into ADSI edit and look up the value. I see the following: Searching for existing values I use the Get-ADUser cmdlet to look for existing values for the UserPrincipalName attribute. To find the value of the UserPrincipalName attribute, I have to specify it for the –Properties parameter. I specify the SearchBase of the organizational unit (OU), and I use the * filter. This is shown here: Get-ADUser -Filter * -SearchBase 'ou=testou,dc=iammred,dc=net' -Properties userPrincipalName The command and associated output are represented in the following image. Setting the UPN value I use the Get-ADUser cmdlet to retrieve all the users to set. I pipe the resulting user objects to the Foreach-Object cmdlet, and in the script block, I use the Set-ADUser cmdlet. The Set-ADUser cmdlet has a –userPrincipalName parameter that makes it easy to set the UPN. To create the UPN, I use a hardcoded domain name, and I get the user’s name from the Name attribute. I use parameter substitution and the –f format specifier to concatenate the user principal name. The command is shown here (this...
  • Links de Interes: Active Directory Disaster and Recovery

    Hola, En el presente post, les dejo links de interés para armado, preparación, prevención y ejecución de Disaster and Recovery. Tenemos que tener la idea en claro, que nuestra infraestructura de Active Directory es el Core...
  • Version de Schema en nuestro Forest

    Hola a todos! En esta oportunidad, quiero dejarles las formas en las que podemos chequear la versión de nuestro Schema de Active Directory, esto identificará la versión de Sistema Operativo de nuestros Domain Controllers, no en...
  • PowerTip: Use PowerShell to Get BitLocker Recovery Key

    Use Windows PowerShell to get the BitLocker recovery key. ...( read more )
  • Revista LatamTechnology #10

    Revista

  • Use PowerShell to Change Sign-in Script and Profile Path

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to modify the sign-in script and profile path in Active Directory. Hey, Scripting Guy! We are in the middle of an Active Directory migration (primarily moving our client computers from Windows XP to Windows 8). We are also consolidating our file servers and our profile servers. We have multiple sites, and in the past, each site had a one or more domain controllers, multiple file and print servers, and other stuff as needed. Now, we are collapsing that infrastructure into a single server running Hyper-V. Needless to say, our profiles will be moving to different servers, and we will also be changing our sign-in scripts. So I need an easy way to modify these settings for our users. The new servers will be based on the user’s city locations. Can you help? —RA Hello RA, Microsoft Scripting Guy, Ed Wilson, is here. Things have been busy around the Scripting House. I got up early to check the scripter@microsoft.com email and to write a couple of proposals for Windows PowerShell Saturday in Atlanta . According to Mark, I will be making two presentations—one for the beginner track and one for the advanced track. In addition, I have been working on my presentation that I will be conducting remotely for Windows PowerShell Saturday in Singapore . Find the attribute names The first thing we need to do is to find the ADSI attribute names for the profile path and for the sign-in script. I open up one of the user profiles and type some bogus information so that I can find the attributes in ADSI Edit. Here is the page from Active Directory Users and Computers: Now I navigate to the same user object in ADSI Edit and look up the ADSI property names. The names make sense: ProfilePath and ScriptPath. This is shown here: Get the information from AD DS Now I need to retrieve the information from Active Directory Domain Services (AD DS). I could do all this from inside the Windows PowerShell console, but I decided to use the Windows PowerShell ISE instead. It has better intellisense, and for something like this, it makes things a bit more readable. I decide to use a couple of variables to hold the organizational unit (OU) and the properties that I need to retrieve. I then use Get-ADUser to retrieve the information. Here is this portion of the script: Import-Module ActiveDirectory $ou = "OU=Testou,Dc=Iammred,Dc=Net" $properties = "ProfilePath...
  • PowerShell Workflow for Mere Mortals: Part 4

    Summary : Microsoft Scripting Guy, Ed Wilson, continues his five-part series about Windows PowerShell Workflow. Hey, Scripting Guy! Yesterday you talked about Windows PowerShell Workflow activities. But you only demonstrated the Parallel activity. Is there something you can share with me about some of the other types of activities? In particular I am interested in checkpoints because I think they can help me. —AP Hello AP, Microsoft Scripting Guy, Ed Wilson, is here. This morning, it is really foggy outside. To be honest, it seems to look more like fall than the end of summer. But then, I am not a real weather person—I don’t even play one on TV. It is fairly humid and fairly cool—a nice morning for a cup of English Breakfast tea. I am not in the mood to experiment today, and so I am going with a standard recipe of mine: Three scoops of English Breakfast tea, a scoop of lemon grass, and a single crushed cinnamon stick. I let it steep for three minutes and 45 seconds, grab my tea pot, my Surface RT, and head outside to check email. AP, you want to talk about checkpoints in a Windows PowerShell workflow today. No problem… Note This is the fourth in a five-part series of blog posts 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 For more information about workflow, see these Hey, Scripting Guy! Blog posts: Windows PowerShell Workflow . Checkpoints Windows PowerShell workflow If I have a Windows PowerShell Workflow, and I need to save the workflow state or data to a disk while the workflow runs, I can configure a checkpoint. In this way, if something interrupts the workflow, it does not need to restart completely. Instead, the workflow resumes from the point of the last checkpoint. Setting a checkpoint in a Windows PowerShell Workflow is sometimes referred to as “persistence” or “persisting a workflow.” Because Windows PowerShell Workflows run on large distributed networks, or they control the execution of long running tasks, it is vital that the workflow can handle interruptions. Understanding checkpoints A checkpoint is a snapshot of the workflow’s current state. This includes the current values of variables and generated output. A checkpoint persists this data to...
  • 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
  • Use PowerShell to Create New Printer Ports

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell 3.0 to create new printer ports in Windows 8. Microsoft Scripting Guy, Ed Wilson, is here. One of the exciting things that is happening around the Scripting House is the appearance of new Windows PowerShell Saturday events. We have new events coming up in Atlanta, Singapore, and Charlotte. For information about these and other events, check out my site, Scripting Community . If you do not know what Windows PowerShell is, check out my blog post, Community: All about PowerShell Saturday . To programmatically create a working printer, there are at least three steps: Create the printer port. Install the printer driver. Install the printer (by using the printer port and the printer driver). Today I am talking about creating the printer port. Using PowerShell to work with printer ports Before I create anything, I like to know what I have going on with my computer. I can use the Get-PrinterPort function to list existing printer ports on my local computer: Get-PrinterPort I can also use this function to retrieve printer port information from a remote server running Windows Server 2008 and Windows PowerShell 3.0 as shown here: Get-PrinterPort -ComputerName dc1 The commands and the output from the commands are shown in the following image. Adding a new printer port To add a new printer port, I use the Add-PrinterPort function in Windows 8 or Windows Server 2012. By using the Add-PrinterPort function, I can add a local printer port, a TCP printer port, or an LPR printer port. Most of the time, if I am creating a local printer port, I want to print directly to a printer on the network. Doing this bypasses a print server. Therefore, in the case of large print jobs, I lose flexibility because my laptop must remain on to manage the large print job. But for short documents, it is fast. Also by printing directly to the printer, I can configure things the way that I want. By using Windows PowerShell, it is easy to create a TCP printer port. I use the Add-PrinterPort function, create a name for the port (the name does not matter, but it is best to use something that makes sense in the printing context). The IP address of the printer itself becomes the value for the PrinterHostAddress parameter. Here is the command I used: Add-PrinterPort -Name 'HP_Direct:' -PrinterHostAddress '192.168.1.88' I do not need to specify a value for the port...
  • Install Printer Drivers with PowerShell in Windows 8

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell in Windows 8 to install printer drivers. Microsoft Scripting Guy, Ed Wilson, is here. This morning, it is rainy and overcast here in Charlotte, North Carolina, but it is pleasantly cool. The Scripting Wife migrated to the lanai and is sitting on her swing and checking Facebook on her Windows RT Surface. I am in my office checking email sent to scripter@microsoft.com . I am sipping a cup of English Breakfast tea with a cinnamon stick, lemon grass, hibiscus blossom, orange peel, and a bit of spearmint. It is a very refreshing cup of tea. When it comes to using Windows PowerShell to install print drivers, there is the long way and the short way. The long way is…well…long and rather complicated. The short way is easy. The difference in the two methods is not necessarily a conscious choice, but rather a function of the drivers already installed in Windows and the print device you intend to hook up. For example, we all know that Windows ships with a whole bunch of printer drivers already on the disk. They reside in the Windows\inf folder, and they all begin with the letters prn . The following script lists the printer drivers that ship with Windows. Get-ChildItem ((Get-Item Env:\systemroot).value+"\inf") -Exclude *.pnf -recurse | Where-Object { $_.name -match "prn" } | Sort-Object -Property name | format-table -Property name, length, creationTime, lastWriteTime -AutoSize Of course, one issue is a bit convoluted. The following image illustrates the output. The issue is that the names, such as prnbrcl1.inf, do not make too much sense. I can go to the Windows/inf directory, and open the .inf file in Notepad, and I am greeting with something that looks like the following. If I compare this output with the output from the advanced printer installation dialog box, I can see similarities. This is shown here. If I select a printer driver from the previous list, and click Next , the driver installs. I can verify this via the Get-PrinterDriver function, as shown here: Get-PrinterDriver The following image shows the command and its output. I can then use the Get-PrinterDriver function to retrieve the newly installed printer: Get-PrinterDriver -Name "Brother *" If I attempt to remove it, however, an error message appears, which states that it is being used by a printer. This command and the error message are shown here....
  • PowerTip: Use PowerShell to Get Printer Configuration

    Summary : Use Windows PowerShell in Windows 8 to find your printer configurations. How can I use Windows PowerShell in Windows 8 to get the printer configuration of all printers? Use the Get-Printer function, and pipe it to Foreach-Object and the Get-PrinterConfiguration cmdlet: Get-Printer | ForEach {Get-PrintConfiguration $_.name}
  • Weekend Scripter: Install Free PowerShell Remote Server Admin Tools

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about installing the free Remote Server Administration Tools for Windows PowerShell 3.0 in Windows 8. Microsoft Scripting Guy, Ed Wilson, is here. This morning is an awesome morning. Our friends from Hamburg, Germany have been hanging out all weekend, and it has been a blast. We have spent a bit of time talking about Windows PowerShell training and some of the challenges related to that. We have also shared a love for tea. Yep. It has been a great weekend. Not only that, but the weather also cooperated—it has been sunny and not too humid. One of the first things I do when I build a new computer running Windows 8, is install the Windows 8 Remote Server Administration Tools (RSAT) tools. After I do this, I gain access to many new and useful cmdlets that make it easy to administer everything from Active Directory Domain Services to Windows Software Update Services. Getting the Windows 8 RSAT tools For a free download of the tools, see Remote Server Administration Tools for Windows 8 on the Microsoft Download Center. There are two versions available on the download page: a 32-bit version and a 64-bit version. Finding the actual download is pretty easy—I click the big red Download button that is shown in the following image. I can install the RSAT tools for Windows 8 on computers running Windows 8 or Windows 8 Pro. I cannot install them on my Windows Surface RT, but I can install them on my Windows Surface Pro. The first thing I need to know is if my computer x86 or is it x64. The way that I usually find this out is to query an environmental variable as shown here: PS C:\Users\ed.IAMMRED> $env:PROCESSOR_ARCHITECTURE x86 Before I install the RSAT tools on my computer, I use the following script to to see how many cmdlets and functions are currently on my computer— I have 989. PS C:\Users\ed.IAMMRED> gcm -CommandType cmdlet, function | measure Count : 989 Average : Sum : Maximum : Minimum : Property : So I click the big red Download button to select my appropriate package. Now, I have a choice. I can download the package and install it offline. Or if I choose Run, the file spools to a Temp folder, and it performs the installation from there. This works great if I have good Internet bandwidth, and if I do not anticipate needing to perform the installation again anytime soon. I will open the file, and after a quick security scan...
  • 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...
  • 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...
  • Redireccionando contenedor default de objetos Computers en AD

    Hola a todos! En esta oportunidad, les quiero dejar como redireccionar el contenedor default donde quedan los objetos Computers al generarse cuando se hace el Join de los equipos a nuestro dominio, como ventaja principal para realizar esta tarea, es...
  • 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: Get-Printer -Name 'mynewlaser' | Rename-Printer -NewName 'myotherlaser'
  • Error "Access is denied" al despromover Domain Controller

    Hola a todos! En esta oportunidad, me gustaria dejarles la solucion a un inconveniente al querer despromover un Domain Controller el cual este operativo y al querer despromoverlo, les aparezca el siguiente mensaje: The operation failed because: Active...
  • PowerTip: Use PowerShell to See Network Adapters Bound to TCP/IP

    Summary : Use Windows PowerShell 3.0 in Windows 8 to see network adapters that are bound to TCP/IP. How can I find all network adapters that are bound to TCP/IPv4 by using Windows PowerShell 3.0 in Windows 8? Use the Get-NetAdapterBinding function, pipe the results to a Where-Object cmdlet, and filter for the BindName equal to ‘tcpip’ : Get-NetAdapterBinding | where bindname -eq 'tcpip'
  • Running PowerShell Scripts from a Remote File Share

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about running Windows PowerShell scripts from a remote file share. Microsoft Scripting Guy, Ed Wilson, is here. It is sort of official… There are at least three Windows PowerShell Saturday events coming up. They are listed on the PowerShell Saturday website. Atlanta and Singapore are already planning (I know, because I will be speaking at both events). The Charlotte event is still early in the planning stages (I will be speaking there also). Of course, don’t just take my word for it. Bookmark the PowerShellSaturday website, so you can keep up to date on all the events. First things first Note For good background info about running Windows PowerShell scripts from a remote file share, check out the guest blog post written by June Blender and Judith Herman: How to Run PowerShell Scripts from a Shared Directory . So I have this shared folder on one of my servers. I can open Windows PowerShell and use the Net View command to see all of the shares. I can then use the Get-ChildItem command ( dir is an alias) to view the files in the shared folder. This is shown here. If I want to look at the files in a GUI, I can type the path into Internet Explorer, and view the files in the File Explorer as shown in the following image. For a background, I happen to know that the remote server is running 32-bit Windows Server 2008. I also found out that the server is running Windows PowerShell 2.0. I did this by using the Invoke-Command cmdlet ( icm is an alias) as shown here: PS C:\> icm -ComputerName dc1 {$PSVersionTable} Name Value ---- ----- PSRemotingProtocolVersion 2.1 BuildVersion 6.0.6002.18111 PSCompatibleVersions {1.0, 2.0} PSVersion 2.0 CLRVersion 2.0.50727.4241 WSManStackVersion 2.0 SerializationVersion 1.1.0.1 Open script in ISE The cool thing is that I can open a Windows PowerShell script in the Windows PowerShell ISE on my 64-bit laptop (running Windows 8a and Windows PowerShell 3.0) from the remote file share. So I do the following: I open the Windows PowerShell ISE. I click File , then Open . In the Open dialog box, I type the UNC path to the remote file share and I press ENTER. I am now viewing the files from the share, as shown in the following image. I view (and edit if required) the script from the remote file share. When I am ready, I click the green triangle (or press F5) to run the script. At the top of the...
  • Redireccionando contenedor default de objetos Users en AD

    Hola a todos! En esta oportunidad, les quiero dejar como redireccionar el contenedor default donde quedan los objetos Users al generarse cuando desde una aplicación, se generan cuentas y se deja al dominio que las genere en un contenedor por...
  • PowerTip: Use PowerShell to Display Locale-Specific Date

    Summary : Learn how to use Windows PowerShell to display the date in locale-specific format. How can I use Windows PowerShell to display the day, month, and two-digit year in locale specific format? Use the Get-Date cmdlet and the –uformat parameter: get-date -UFormat %x
  • Deciding How to Use PowerShell to Access AD DS

    Summary : Microsoft Scripting Guy, Ed Wilson, talks about the decision points for deciding how to use Windows PowerShell to access Active Directory Domain Services. Hey, Scripting Guy! I am a bit confused. I see various blogs and scripts on the Script Repository, and some always use a third-party snap-in to access Active Directory Directory Domain Services (AD DS). Others seem to use .NET Framework code to access AD DS, and still others are using a module that looks like it is part of Windows PowerShell. What is the best way to access AD DS? —CB Hello CB, Microsoft Scripting Guy, Ed Wilson, is here. This morning it is actually cool here in Charlotte, North Carolina. In fact, it is way cool because the Scripting Wife found a place on the Internet so she could order some chocolate covered Macadamia nuts. By the way, they go very well with Earl Grey tea with a cinnamon stick. The chocolate, the cinnamon, and the touch of bergamot combine to create an exquisite taste sensation. So, I am out on the lanai sipping tea, nibbling on chocolate covered Macadamia nuts and checking my email on my Surface RT, and I ran across this email to scripter@microsoft.com from CB. Supportability—the big advantage When comparing options for working with Active Directory Domain Services from within Windows PowerShell, one option stands above all the others: supportability. When I use the Active Directory module from Microsoft, it is supported. For me, this means a lot. So if something does not work out perfectly, I know it is supported. I gain access to the Active Directory module in two ways. On a domain controller that is running at least Windows Server 2008 R2, I add the Active Directory management feature, and I have access to the Active Directory module. I can access it locally on the server, or I can use remoting or implicit remoting to access the cmdlets from my workstation. For more information about remoting, see Use PowerShell Active Directory Cmdlets Without Installing Any Software . I can also install the Remote Server Admin Tools (RSAT) on my workstation. The version I install depends on the version of the operating system that I have on my workstation. For more information, see What's Up with Active Directory Domain Services Cmdlets? Note If I install Active Directory Management Service for Windows Server 2008, I do not get access to the Active Directory module on the server. I must install the RSAT tools on my workstation for management...
  • PowerShell Workflow for Mere Mortals: Part 3

    Summary : Microsoft Scripting Guy Ed Wilson continues his five-part series about Windows PowerShell Workflow. Hey, Scripting Guy! So what’s up with Windows PowerShell workflows and activities? I do not know what an activity is. Can you help me? —CJ Hello CJ, Microsoft Scripting Guy, Ed Wilson, is here. Ah…this afternoon, I am sipping a cup of Darjeeling Earl Grey tea with a bit of cinnamon stick, and I added just a bit of lavender honey from a nearby lavender farm. I am accompanying my tea with a 90% cocoa bar with black currants and hazelnuts. The combination is absolutely stunning. Note This is the third in a five-part series of blog posts 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 For more information about workflow, see these Hey, Scripting Guy! Blog posts: Windows PowerShell Workflow . Workflow activities A Windows PowerShell Workflow is made up of a series of activities. In fact, the basic unit of work in a Windows PowerShell Workflow is called an activity. There are five types of Windows PowerShell Workflow activities that are available for use. The following table describes the types of activities. Activity Description CheckPoint-Workflow (alias = PSPersist) Takes a checkpoint. Saves the state and data of a workflow in progress. If the workflow is interrupted or rerun, it can restart from any checkpoint. Use the Checkpoint-Workflow activity along with the PSPersist workflow common parameter and the PSPersistPreference variable to make your workflow robust and recoverable. ForEach -Parallel Runs the statements in the script block once for each item in a collection. The items are processed in parallel. The statements in the script block run sequentially. Parallel Allows all statements in the script block to run at the same time. The order of execution is undefined. Sequence Creates a block of sequential statements within a parallel script block. The Sequence script block runs in parallel with other activities in the Parallel script block. However, the statements in the Sequence script block run in the order in which they appear. Sequence is valid only within a Parallel script block. Suspend-Workflow ...
  • 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...