Thursday, April 28, 2011

Search Active Directory for user properties

We are working on a project where we need to gather user telephone numbers from Active Directory in order to verify and normalize the telephone number filed.  This filed has to be formatted in a certain way and it also must be unique to a user, or the integration of Exchange and Cisco Unity Connection will not work.  My first thought was to use DSquery and DSget, but I decided to use the Get-ADuser Powershell cmdlet. 

In this case I just wanted First and Lastname and office telephone number.  So I used the following PS scripts 

From the Windows 2008 r2 AD Powershell Module:
Get-Aduser –Filter * -properties TelephoneNumber | FT Name,TelephoneNumber | Out-File C:\telnumberdump.txt

I like to dump results to TXT file, so I formatted the output  to deisplay Name and Telephone Number and then saved it to C: with Out-File. 


TechNet PS User Management

Backup and Restore NTFS and Share Permissions 2

NTFS permissions are stored as part of the file system itself, in an attribute in the Master File Table. So the backup and restore of NTFS permissions is somewhat different than Share Permissions.  Windows Server 2008 r2 is comes with a native utility to fulfill this purpose.

I used the following command to backup and restore the NTFS permissions: 
Backup and Restore NTFS:

icacls E:\Users\*   /save C:\NTFSPerm /T /C

The /T switch recourses through the directory to get sub folder and files, while the /C switch continues on error.

Restore:

icacls E:\ /restore C:\NTFSPerms.txt /C

When restoring the NTFS permissions only include the drive path and use the /C  switch to continue on error.

ICACLS Wiki

Friday, April 22, 2011

Backup and Restore NTFS and Share Permissions

We are in the process of migrating/upgrading our File and Application servers to Windows Server 2008r2.  Virtualization has really done away with hardware migration issues, but we still have to worry about OS and Application specific settings.

One task that is part of the server migration process is the backup and restore of the NTFS and Share permissions.  The Windows 2008 r2 server migration wizard facilitates the transfer of these settings, but I like to err on the side of caution and prefer to manually back them up. Share permissions are stored in the registry, so the backup of Share permissions is as easy as exporting a Registry Key.

Export the following reg key to a new file by right clicking on the Share reg Key and selecting Export.

HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares

CommandLine:
reg export HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares share.reg

To import by using the registry.exe, just double click on the reg key on the destination server.

CommandLin:
reg import share.reg

Windows Server 2008 VSS Space Usage

Quick note about Volume Shadow Copy (VSS).   VSS can be configured to use Space Limits or it can be configured to use all allocated space (No Limits).

When configured to use limits, VSS will purge old Snapshots when the limit is met.  No Limit configuration will start to purge the oldest Snapshots once physical allocated space has been used.  I chose to use the No limits option to maximize our Snapshot retention period.

Check Space used by VSS:
Vssadmin list ShadowCopyStorage

Thursday, April 14, 2011

PowerShell Script Get DirectorySize

This is more General Powershell script used to gather folder size infomration from our Home Directory server.

$startfolder = "E:\users\*"
$folders = get-childitem $startfolder | where{$_.PSiscontainer -eq "True"}
"Directory Name`tDirectory Size (MB)"
foreach ($fol in $Folders){
$colItems = (Get-ChildItem $fol.fullname -recurse | Measure-Object -property length -sum)
$size = "{0:N2}" -f ($colItems.sum / 1MB)
"$($fol.name)`t$size"
}



Thanks to the "Hey Scripting Guy" team

Wednesday, April 13, 2011

Netbackup Commands

Useful Netbackup commands to help troubleshoot.

Verifies DNS resolution
C:\Program Files\veritas\netbackup\bin
bpclntcmd -hn ClientName

DNS Reverse Lookup
C:\Program Files\veritas\netbackup\bin 
bpclntcmd -ip ClientIP

Clear Resource Allocation
installpath\bin\admincmd
nbrbutil -resetall

Resource Allocation Log
nbrbutil -dump

Netbackup jjob cleanup fails with status code 83
Run the following command:
nbdelete -allvolumes -force

nbdelete can be found in the following locations:
Windows: <install_path>\VERITAS\NetBackup\bin\admincmd






Tuesday, April 12, 2011

Netbackup Display Tape Drive Status (vmoprcmd)

This command will display the status of all drives attached to a netbackup media server.   I usually run it from the master server.  This command can run with switches, but I get the results I need by executing it on its own.

1.    Command Prompt.
2.    Cd C:\Program files\VERITAS\volmgr\bin\vmoprcmd.