Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Wednesday, February 24, 2010

How to control which files are cached in branch cache.

You can control which files are in the Brach Cache on your Branch Cache Server. Once you install Branch Cache, you can enable it on all file shares or on a per-folder basis. Once you have the BranchCache feature installed, go to the properties of one of the folders that you want to enable Branch Cache on.

· Click the Sharing tab.

· Click Advanced Sharing.

· Click the Caching button.

· Under Only the files and programs that users specify are available offline, Check the box for Enable BranchCache.

Monday, February 22, 2010

Why are there ActiveX GPOs for IE trusted zones.

GPOs (Group Policy Objects) allow us to do a one-to-many administration of our clients. The question is why do we need ActiveX group policy objects for IE. Well, ActiveX controllers allow your web browsers to have more functionality. They let your users do more in a web page. They can also be malacious. The ActiveX GPO settings allow you to control what type of ActiveX controls your users can instal, and from where. By designatation ActiveX restriction in your IE trusted zones, you can make sure that your ActiveX controllers are properly tested prior to allowing them to be installed on your clients. The link below explains more about the individual GPOs for ActiveX.

http://technet.microsoft.com/en-us/library/bb457144.aspx

Wednesday, February 17, 2010

CodeBaseSearch value for redirecting ActiveX

In class, we discussed the ability of Windows 7 to utilize a central server for all ActiveX installs. The advantage to this is you get to choose which ActiveX controllers are approved for your organization. The attached link from Microsoft will guide you in configuring this central site. The CodeBaseSearch string is the location of the central web server that hosts you ActiveX control repository.

http://technet.microsoft.com/en-us/library/cc721964(WS.10).aspx

Monday, February 15, 2010

What are the event IDs in the System Log when a user exceeds their Quota.

Disk Quotas are easy ways of making sure that a single user does not consum all of your network storage space. On an individual computer, it makes sure the user does not consume space that you need for future applications. I did a quick test run to get the correct event log enteries for quotas. In class, we had some that were generating log enties and some that were not. When properly configured, you will get enteries for:

Exceeded warning threshold:

  • Event ID: 36
  • Cource Ntfs
  • Log: System
  • Message: A user hit their quota threshold on volume volume label:

When the user hits their quota limit:

  • Event ID: 37
  • Cource Ntfs
  • Log: System
  • Message: A user hit their quota threshold on volume volume label:

The difference between both messages is the Event ID.

In using the Netsh BranchCache command, what does the importkey and exportkey do?

Branch Cache is a new feature in Windows 7/2008 R2 that allows your Windows 7 clients (or 2008 R2 server) to cache documents in a local site, as opposed to having to accessed shared documents over a slow connection. The expoertkey and importkey switches are used to designate a file that stores a key that is used to generate a hash of the file.

For more information: http://technet.microsoft.com/en-us/library/dd979561(WS.10).aspx

Wednesday, February 10, 2010

How do you know which hardware ID the client used to match a driver to?

To find out which hardware ID was used in driver selection, we need to take a look at two properties of the driver. The Hardware ID and the Driver Node Strong Name.

Every PnP device has a set of hardware Ids that are set by the manufacture. They range from specifically identifying the device. The manufacture will also include some IDs that are a close match. When Windows starts up, it enumerates all devices in the computer. It ranks them with the most specific hardware ID with a rank of zero. It will then try to match a driver in the driver store to the hardware ID with the lowest rank. If a driver is not available for the ID with the lowest rank, it tries to match a driver to the next ID in the list. The question is, which hardware ID was used?

· Open your Device Manager.

· Select a device. (It must be one that does not have any issues.)

· Go to its properties.

· Click Details tab.

· Select Driver Node Strong Name from the drop down list. This attribute is populated with a string that identifies the driver used. At the end of the string is the Hardware ID used.

· Select Hardware Ids from the drop down list and compare.

Monday, February 8, 2010

What does the /uel option do in User State Migration Tool.

User State Migration Tool (USMT) is a scriptable tool that is used to transfer the user data so you can upgrade an OS or provide them with a new computer. It is designed to retain most of there user experience from the previous computer and to make sure that their data is where it is supposed to be. The question that came up is, what does the /UEL option do?

The /uel switch replaces the /user option from previous version of USMT. It allows you to migrate only users that have logged into the source computer within a specific amount of time. This prevents you from transferring data from users who may have logged into that machine for some reason in the distant path, but most likely do not need their profiles moved.

The syntax for this option in the SCANSTATE command is [/uel:NumberOfDays|YYYY/MM/DD|0]

/uel:0 will migrate all data for any user who is currently logged on.

/uel:90 will migrate data for all users who have logged on in the last 90 days.

/uel:2002/1/15 migrates user data for all users who have logged into this computer since January 15, 2002.

Reference: http://technet.microsoft.com/en-us/library/cc749015(WS.10).aspx

Wednesday, February 3, 2010

Is system center Configuration Manager used for zero touch deployment?

Yes it is. You can find more information on deploying a zero touch installation of Windows 7 at http://www.microsoft.com/systemcenter/configurationmanager/en/us/default.aspx

Tuesday, February 2, 2010

Using PowerShell to Manage AD DS Recycle Bin

We learned last Tuesday how to turn on the AD DS Recycle Bin using PowerShell. To help manage the recovery process and cut down on you typing, try the script below. It will help you find the objects you are looking to recover. It is provided as is. For easier reading, copy and paste it into Notepad.

# ===========================================================

# Script Name: ADRecycleBin.PS1

# Author: Jason A. Yoder, MCT

# Website: www.MCTExpert.com

# Blog: www.MCTExpert.Blogspot.com

# ===========================================================

# ===========================================================

# Script Purpose:

# This script is designed to make it easier to recover

# objects from the Active Directory Recycle Bin on a

# Windows Server 2008 R2 Domain Controller.

#

# ===========================================================

# ===========================================================

# Script Requirments

# 1. This script must be run on a Windows Server 2008 R2

# Domain Controller

# 2. Active Directory Recycle Bin must be enabled prior

# to deleting objects. All Objects deleted prior

# to enabling Active Directory Recycle Bin will not

# be recoverable.

# 3. Parent containers of any deleted objects must

# first be restored

# ===========================================================

# ===========================================================

# Known Issues:

# Issue 1:

# When selectiong from the list of names to restore, if

# you select the last name of the list, it will not restore.

#

# Workaround 1:

# Create a user object and delete it. Run the script

# again. The object you want to restore will no longer be

# last on the list and will restore.

# ===========================================================

# ===========================================================

# Revision History:

#

# ===========================================================

# ===========================================================

# Global Varibles

#

# $ScriptMode - Script mode will have two options.

# 1. Search for objects by date.

# 2. Search for objects by name.

$ScriptMode = 0

# $DaysBack - The number of days the script should look

# back for deleted objects.

$DaysBack = 0

# $LookUpName - All or part of the object name that the

# script should filter for.

$LookUpName = ""

# $NameArray - Array that holds the names of all the

# returned deleted objects from the recycle bin query.

$NameArray += @(0)

# $RecoveryName - The Name of the object to recover.

$RecoveryName = ""

# == End of Global Variables ================================

# ===========================================================

# Functions

#

# DisplayTitle - Display the welcome screen

Function Display_Title()

{

$Text = "`

===========================================`

== ADRecycleBin.PS1 ==`

== ==`

== Author: Jason A. Yoder, MCT ==`

== ==`

== Disclaimer: ==`

== This script is provided as is with no ==`

== guarantee or support. Test throughly ==`

== before deploying in you environment. ==

==========================================="

Write-Host $Text

} # End of functionL DisplayTitle

# -----------------------------------------------------------

# GetScriptMode - Asks the user Which operation mode the

# script should run in.

Function GetScriptMode()

{

$Text = "`

ADRecycleBin.ps1 allows you to search the AD Recycle bin`

but looking back X number of days or by specifing the`

object name. Please choose how you want to search`

the recycle bin.`

`

1 - By Day.`

2 - By Name.`

"

#Save user's choice in $ScriptMode.

$Script:ScriptMode = Read-Host $Text

} # End of Function: GetScriptMode

# -----------------------------------------------------------

# SearchDays - Asks the user for how many days to look back

# for deleted objects.

Function SearchDays()

{

$Text = "`

Enter in the number of days to look back for deleted`

deleted objects in the AD Recycle Bin."

#Save user's choice in $DaysBack

$Script:DaysBack = Read-Host $Text

} # End of Function: SearchDays

# -----------------------------------------------------------

# SearchName - Asks the user for part of the objects

# name they are looking for.

Function SearchName()

{

$Text = "`

Enter in the number all or part of the objects`

name that you are looking for."

#Save user's choice in $LookUpName

$Script:LookUpName = Read-Host $Text

} # End of Function: SearchName

# -----------------------------------------------------------

# GetDaysObjects - Queires AD for a list of all deleted

# AD Objects over the past $DaysBack and puts the names

# into an array.

Function GetDaysObjects

{

# Get the current date and save it in $CurrentData.

# This is used as the starting point to determin how many

# days to go back.

$CurrentDate = get-date

# Take the number of days selected by the user and

# negate it for DateTime Arythmitic.

$Days = [int]$DaysBack * (-1)

# Find the date minus the users specified number of

# days using the AddDays method.

$NewDate = $CurrentDate.AddDays($Days)

# Create a new date time object that has its date as

# the day specified by the user. Also have the time set

# at 12:01 AM.

$ChangeDate = New-Object DateTime([String]$NewDate.Year,[String]$NewDate.Month,`

[String]$NewDate.Day,0,0,1)

# Extract all objects in the AD Recycle Bin that is deleted

# and is within the users specified range of time.

#Placed the objects in the array $Data.

$Data = Get-ADObject -Filter 'WhenChanged -gt $ChangeDate -and isDeleted -eq $true' -includeDeletedObjects

#Determine the number of records in the array.

$Index = $Data.count

# Because of extra data returned in the 'Name' property

# of the objects, below we will cycle through

# the array and use Regular Expressions to

# extract the first name in the 'Name' property.

For ($X=0; $X -le $Index-1; $X++)

{

$Data[$X].Name -match "\w*"

$Script:NameArray += $Matches.Values

}

CLS

} # End of FunctionL GetDaysObject

# -----------------------------------------------------------

# GetNameObject - Queires AD for a list of all deleted

# AD Objects With a name like $LookUpName and puts the names

# into an array.

Function GetNameObject

{

# Set the script variable $LookUpName to a the local

# variable $Name. This is because the command line

# below does not recognize variable scopes other

# then local.

$Name = $Script:LookUpName

$Data = Get-ADObject -Filter {displayname -like $Name -and isDeleted -eq $true} -includeDeletedObjects

# Because of extra data returned in the 'Name' property

# of the objects, below we will use Regular Expressions

# to extract the first name in the 'Name' property.

$Data.Name -match "\w*"

$Script:NameArray += $Matches.Values

} # End of Function: GetNameObject

# -----------------------------------------------------------

# GetRecoveryOption - Will display and numeric list of the

# names of the objects from the query and ask the user to

# select which one to recover.

Function GetRecoveryOption

{

Write-Host " Please select the number of the object`

that you would like to recover."

Write-Host "Index`t Name"

Write-Host "-----`t ---------------"

# Write out the array of possible objects to

# restore and put and index number in front

# of them.

$Index = $Script:NameArray.Count

For ($X=1; $X -le $Index-1; $X++)

{

Write-Host $X`t $Script:NameArray[[int]$X]

}

# Allow the user to select a number and store it

# in $Option.

$Option = Read-host {"Please Select a number."}

# Set the Script variable with the name of

# the users choice.

$Script:RecoveryName = $Script:NameArray[$Option]

} # End of Function: GetRecoveryOption

# -----------------------------------------------------------

# RecoverObject - Executes the recovery command for the

# object.

Function RecoverObject

{

# Set the script variable $RecoveryName to a the local

# variable $Name. This is because the command line

# below does not recognize variable scopes other

# then local.

$Name = $Script:RecoveryName

Write-Host "Recovering object $Name"

#The command below executes the restore process.

get-adobject -filter {DisplayName -like $Name} -IncludeDeletedObjects | Restore-ADObject

} # End of Function: RecoverObject

# == End of Functions =======================================

# ===========================================================

# Main Code:

cls

Display_Title

GetScriptMode

# From here the script will collect data depending on the

# $ScriptMode variabe

Switch ($ScriptMode)

{

1 {

SearchDays

GetDaysObjects

}

2 {

SearchName

GetNameObject

}

Default {"Error, invaild option"}

}

GetRecoveryOption

RecoverObject

#

# == End of Main Code =======================================

Monday, February 1, 2010

6422A-Implementing and Managing Windows Server 2008 Hyper-V is now available through MCTExpert.

6422A-Implementing and Managing Windows Server 2008 Hyper-V has been added to the course offerings from MCTExpert. Hyper-V is Microsoft's latest virtualization solution. If you have not tried virtualization, or are interested in its potential, you need to look into this class.

I've been utilizing Hyper-V for over a year now. Those of you who have been in my classes know that I bring my test environment with me and I use it to simulate your questions. In this class we will also learn how to utilize System Center Virtual Machine Manager to help our developers and testing staff.