PowerShell for Windows Admins

Dec 7 2011   3:09PM GMT

Backing up the WMI repository

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The WMI repository is a collection of files. It can be easily backed up

function backup-wmirepository {            
 param(            
  [string]$path,            
  [switch]$force            
 )            
             
 if ($force){            
  if (Test-Path $path){Remove-Item -Path $path -Force}            
 }            
 else {            
   if (Test-Path $path){Throw "$path already exists"}            
 }            
 $exp = "winmgmt /backup $path"            
             
 Invoke-Expression -Command $exp             
            
}

The function will back up the repository to the given file unless the file exists. if you want the backup file overwritten use the force switch

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: