Condividi tramite


Remove-SCLibraryServer

Remove-SCLibraryServer

Removes a library server from VMM.

Syntax

Parameter Set: Default
Remove-SCLibraryServer [-LibraryServer] <LibraryServer> -Credential <VMMCredential> [-JobVariable <String> ] [-PROTipID <Guid]> ] [-RunAsynchronously] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Remove-SCLibraryServer cmdlet removes a library server object and all library objects on that library server from the Virtual Machine Manager (VMM) database. Library objects that have a corresponding file, such as .vhd or .vmdk files, stored on the server 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.

Parameters

-Credential<VMMCredential>

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.

For more information about the PSCredential object, type Get-Help Get-Credential.

For more information about Run As accounts, type Get-Help New-SCRunAsAccount.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobVariable<String>

Specifies that job progress is tracked and stored in the variable named by this parameter.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LibraryServer<LibraryServer>

Specifies a VMM library server object.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-PROTipID<Guid]>

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Example 1: Remove a library server object from VMM

The first command prompts you for credentials. For more information, type Get-Help Get-Credential. 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 command stores the credentials in the $Creds variable.

The second command retrieves the library server object named LibraryServer01 on VMMServer01, and then 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.

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

Example Example 2: Remove multiple library server objects that have a specific string in their name.

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 command stores the credentials in the $Creds variable.

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. That cmdlet removes each object from VMM.

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

Example 3: Remove a highly available library server and all of its nodes

The first command uses Get-Credential to prompt you to supply a user name and password, and then 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 then 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 statement to pass each object stored in $Cluster.ClusterNodes to the Remove-SCLibraryServer 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 statement, type Get-Help about_ForEach.

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}

Add-SCLibraryServer

Find-SCCluster

Get-Credential

Get-SCLibraryServer

Remove-SCLibraryShare

Restart-SCJob

Set-SCLibraryServer