Episode 13 – Stop-Computer – Restart-Computer

Download the MP3 Podcast

In this episode we look at how you can power down or reboot computers on your network. We also realize that this is the easiest way to learn how to do the same for any Windows 8 computer.

Restart-Computer -ComputerName (gc c:\computerlist.txt) -ThrottleLimit 64 -Force

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 12 – Variable, Env, Function Provider

Download the MP3 Podcast

In this episode we look at a few commonly overlooked providers and what they contain.

Try the following:

cd variable:
dir

cd env:
dir

cd function:
dir

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 11 – Export-CSV – ConvertTo-CSV

Download the MP3 Podcast

In this episode we look at how we can turn PowerShell objects into comma separated strings and files

Append Example:

Get-Process |select name,id |ConvertTo-Csv -NoTypeInformation |select -Skip 1 |out-file filetoappend.txt

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 10 – Select-Object

Download the MP3 Podcast

In this episode we explore all of the possibilities for one of the most used PowerShell cmdlets.

Basic Example:

Get-Process |select name, id

Parameters discussed:

  • First
  • Last
  • Skip
  • Unique

Return a string collection of the process names rather than an object with only a name property

Get-Process |select -ExpandProperty Name

Return the collection that exists within the access property

Get-Acl |select -ExpandProperty Access

Create a custom property with Name/Expression Hash

Get-Process |select @{Name='Modified Name';Expression={$_.Name + "_Modified"}}

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 9 – Out-Null

Download the MP3 Podcast

In this episode we look at how you can stop the pipeline and suppress output with Out-Null.

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 8 – Break and Continue

Download the MP3 Podcast

In this episode we look at how you can use break and continue to control the flow of loops.

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 7 – Join-Path

Download the MP3 PodcastIn this episode we look at how you can easily concatenate paths with Join-Path.

$dir = 'C:\users'
$child = 'tome'
Join-Path $dir $child
c:\users\tome

Join-Path c:,d: NewDir
c:\NewDir
d:\NewDir

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 6 – Split-Path

Download the MP3 Podcast

In this episode we look at how you can carve up strings that make up strings of text that make up paths with Split-Path:

By default – returns parent path

Split-Path c:\users\tome
c:\user

Leaf - returns the end of the path (file or directory name)

Split-Path c:\users\tome -Leaf
tome

NoQualifier – removes the drive letter from the path

Split-path hklm:\software\microsoft -NoQualifier
\software\microsoft

Qualifier – returns just the drive letter

Split-path c:\users\tome
c:\

IsAbsolute – returns true if it is an absolute path, not a relative path.

Resolve – evaluates the string path to a real path

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 5 – BackupRestoreImport-GPO

Download the MP3 Podcast

In this episode we look at how you can Backup, Restore, and Import Group Policy Objects using Windows PowerShell and the cmdlets that come with the Group Policy module in the latest version of RSAT and the GPMC.

$dir = '\\server1\gpobackups'

# Backups
Get-GPO -All |Backup-GPO -Path $dir
Get-GPO remoting |Backup-GPO -Path $dir

#Restore
Restore-GPO -Path $dir -All
Restore-GPO -Path $dir -Name remoting

# Restore a GPO from a specific backup
$id = '00003D27-F9E6-4C59-BF69-938E5AE43D05'
Restore-GPO -Path $dir -BackupId $id

# Create a new GPO named remoting2
Import-GPO -Path $dir -BackupGpoName remoting -TargetName remoting2 -CreateIfNeeded

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 4 – Get-GPResultantSetOfPolicy

Download the MP3 Podcast

In this episode we look at how you can generate an RSOP with Windows PowerShell by using Get-GPResultantSetOfPolicy by using the GroupPolicy module that comes with the GPMC that is bundled in Windows Server 2008 R2 and the most recent version of RSAT.

# Populate dir with the current dir regardless of whether
# you are in a script or executing in the shell
if ($MyInvocation.MyCommand.Path) {
    $dir = $MyInvocation.MyCommand.Path
}
else {
    $dir = $pwd
}

$user = 'home\Administrator'
$report = Join-Path $dir 'rsop.html'
$comp = 'Server1'
Get-GPResultantSetOfPolicy -User $user -Path $report -ReportType HTML -Computer $comp

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Follow

Get every new post delivered to your Inbox.