Remove-SCLibraryServer

Removes a library server from VMM.

Description

The Remove-SCLibraryServer cmdlet removes a library server object (and all library objects on that library server) from the System Center Virtual Machine Manager (VMM) database. Library objects that have a corresponding file (such as .vhd or .vmdk files) stored on the server's file system are not removed from the file system by this cmdlet.

This cmdlet operates as follows:

- If this library server is also the VMM server, you cannot remove the 
  library server, so the remove library server operation will fail.

- If this computer is both a library server and a host, this cmdlet
  removes only the library server feature from VMM, but the 
  computer continues to function as a host. 

- If this computer is only a library server (not also a host or a VMM 
  server), the library server is removed from VMM.

This cmdlet returns the object upon success (with the property MarkedForDeletion set to TRUE) or returns an error message upon failure.

For more information about Remove-SCLibrary server, type: "Get-Help Remove-SCLibraryServer -online".

Parameters

LibraryServer

Required? true
Accept Pipeline Input? true (ByValue)
Position? 0
Specifies a VMM library server object.

Credential

Required? true
Accept Pipeline Input? false
Position? named
Specifies a credential object or, for some cmdlets, a Run As account object that contains the user name and password of an account that has permission to perform this action. Or, in the case of Restart-SCJob, has permission to complete a restarted task. 

For more information about the PSCredential object, type: "Get-Help Get-Credential". 
For more information about Run As accounts, type: "Get-Help New-SCRunAsAccount".

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

Examples

1: Remove a library server object from VMM.
PS C:\> $Creds = Get-Credential
PS C:\> $LibServ = Get-SCLibraryServer -VMMServer "VMMServer1.Contoso.com" -ComputerName “LibraryServer01.Contoso.com”
PS C:\> Remove-SCLibraryServer -LibraryServer $LibServ -Credential $Creds
The first command prompts you for credentials. When the dialog box appears, type the user name and password for either a local Administrator account or a domain account with administrator rights on the library server.

The second command retrieves the library server object named LibraryServer01 on VMMServer01 and stores it in the $LibServ variable. 

The third command removes the library server object, and all library shares on this server, from the VMM library. When the Remove-SCLibraryServer cmdlet is used with the -LibraryServer parameter as shown in this example, you can pass only one library server object to the cmdlet.
2: Remove multiple library server objects that have a specific string in their name.
PS C:\> $Creds = Get-Credential
PS C:\> $LibServers = Get-SCLibraryServer -VMMServer "VMMServer01.Contoso.com" | where { $_.Name -match “LibraryServer” }
PS C:\> $LibServers | Remove-SCLibraryServer -Credential $Creds
The first command prompts you for credentials. When the dialog box appears, type the user name and password for either a local Administrator account or a domain account with administrator rights on the library server.

The second command gets all library server objects from VMMServer01 with names that include the string "LibraryServer" and stores the returned objects in the $LibServers variable (an object array). 

The third command passes each library server object in $LibServers to Remove-SCLibraryServer, which removes each object from VMM.
3: Remove a highly available library server and all of its nodes.
PS C:\> $Credential = Get-Credential
PS C:\> $Cluster = Find-SCCluster -ComputerName "HAFileServer01.Contoso.com" -Credential $Credential
PS C:\> Remove-LibraryServer -LibraryServer "HAFileServer01.Contoso.com" -Credential $Credential -RunAsynchronously
PS C:\> ForEach ($Node in $Cluster.ClusterNodes) {Remove-LibraryServer -LibraryServer $Node -Credential $Credential -RunAsynchronously}
The first command uses Get-Credential to prompt you to supply a user name and password and stores your credentials in $Credential. The required credentials for this operation are either a local Administrator account or a domain account with administrator rights on the library server. The following commands use $Credential to pass your credentials to each cmdlet that requires credentials.

The second command uses the Find-SCCluster cmdlet  to confirm that HAFileServer01 is a highly available file server and stores the cluster object in the $Cluster variable.

The third command removes the highly available file server (by specifying its name) as a library server from VMM. The command uses the -RunAsynchronously parameter to return control to the shell immediately (before this command completes) because the last command does not need to wait until after this command finishes.

The last command uses a foreach loop to pass each object stored in $Cluster.ClusterNodes to the Remove-LibraryServer cmdlet, which removes each node from VMM. The command uses the -RunAsynchronously parameter to return control to the shell immediately. For more information about the Windows PowerShell foreach loop statement, type: "Get-Help about_ForEach".

See Also