Tag Archives: Confirm

Update-TypeData

NAME
    Update-TypeData

SYNOPSIS
    Updates the current extended type configuration by reloading the *.types.ps1xml files into memory.

SYNTAX
    Update-TypeData [[-AppendPath] <string[]>] [-PrependPath <string[]>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Update-TypeData cmdlet updates the current extended type configuration by reloading the *.types.ps1xml files into memory. Extended type information is normally loaded when Windows PowerShell requires the type information it contains. The Update-TypeData cmdlet can be used to preload all type information. It is particularly useful when you are developing types and want to load those new types for testing purposes.

    For more information about the *types.ps1xml files in Windows PowerShell, see about_types.ps1xml.

PARAMETERS
    -AppendPath <string[]>
        Specifies the path to the optional .ps1xml files that will be included in the list of files loaded. These are processed after the built-in files are loaded.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        Accept wildcard characters? false

    -PrependPath <string[]>
        Specifies the path to the optional .ps1xml files that will be included in the list of files loaded. However, these files are processed in the order they are specified and before the built-in files are loaded.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains the append path to Update-TypeData.

OUTPUTS
    None
        This cmdlet does not return any output.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>Update-TypeData

    Description
    ———–
    This example updates the extended type configuration from the *.types.ps1xml files.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Update-TypeData -PrependPath typesA.types.Ps1xml, typesB.types.Ps1xml

    Description
    ———–
    This example updates the extended type configuration from the *.types.ps1xml files, processing the typesA and typesB files first.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113421

Undo-Transaction

NAME
    Undo-Transaction

SYNOPSIS
    Rolls back the active transaction.

SYNTAX
    Undo-Transaction [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Undo-Transaction cmdlet rolls back the active transaction. When you roll back a transaction, the changes made by the commands in the transaction are discarded and the data is restored to its original form.

    If the transaction includes multiple subscribers, an Undo-Transaction command rolls back the entire transaction for all subscribers.

    By default, transactions are rolled back automatically if any command in the transaction generates an error. However, transactions can be started with a different rollback preference and you can use this cmdlet to roll back the active transaction at any time.

    The Undo-Transaction cmdlet is one of a set of cmdlets that support the transactions feature in Windows PowerShell. For more information, see about_transactions.

PARAMETERS
    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    None
        This cmdlet does not return any output.

NOTES

        You cannot roll back a transaction that has been committed.

        You cannot roll back any transaction other than the active transaction. To roll back a different, independent transaction, you must first commit or roll back the active transaction.

        Rolling back the transaction ends the transaction. To use a transaction again, you must start a new transaction.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Undo-Transaction

    Description
    ———–
    This command rolls back the current (active) transaction.

    ————————– EXAMPLE 2 ————————–

    C:\PS>cd hkcu:\software

    PS HKCU:\Software> Start-Transaction
    PS HKCU:\Software> New-Item MyCompany -usetransaction
    PS HKCU:\Software> Undo-Transaction

    Description
    ———–
    This command starts a transaction and then rolls it back. As a result, no changes are made to the Registry.

    ————————– EXAMPLE 3 ————————–

    C:\PS>cd hkcu:\software

    PS HKCU:\Software> Start-Transaction
    PS HKCU:\Software> New-Item MyCompany -usetransaction
    PS HKCU:\Software> Get-Transaction

    RollbackPreference SubscriberCount Status
    —————— ————— —–
    Error                1                 Active

    PS HKCU:\Software> Start-Transaction
    PS HKCU:\Software> Get-Transaction

    RollbackPreference SubscriberCount Status
    —————— ————— —–
    Error                2                 Active

    PS HKCU:\Software> Undo-Transaction
    PS HKCU:\Software> Get-Transaction

    RollbackPreference SubscriberCount Status
    —————— ————— —–
    Error                0                 RolledBack

    Description
    ———–
    This example demonstrates that when any subscriber rolls back a transaction, the entire transaction is rolled back for all subscribers.

    The first command changes the location to the HKCU:\Software Registry key.

    The second command starts a transaction.

    The third command uses the New-Item cmdlet to create a new Registry key. The command uses the UseTransaction parameter to include the change in the transaction.

    The fourth command uses the Get-Transaction cmdlet to get the active transaction. Notice that the status is Active and the subscriber count is 1.

    The fifth command uses the Start-Transaction command again. Typically,
    starting a transaction while another transaction is in progress occurs when a script used by the main transaction includes its own complete transaction. (This example is done interactively so that you can examine it in stages.)

    When you enter a Start-Transaction command while another transaction is in progress, the commands join the existing transaction as a new “subscriber” and the subscriber count is incremented.

    The sixth command uses the Get-Transaction cmdlet to get the active transaction. Notice that the subscriber count is now 2.

    The seventh command uses the Undo-Transaction cmdlet to roll back the transaction. This command does not return any objects.

    The final command is a Get-Transaction command that gets the active (or in this case, the most recently active) transaction. The results show that the transaction is rolled back, and that the subscriber count is 0, showing that the transaction was rolled back for all subscribers.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135268
    about_transactions
    about_providers
    Start-Transaction
    Get-Transaction
    Complete-Transaction
    Use-Transaction

Unregister-Event

NAME
    Unregister-Event

SYNOPSIS
    Cancels an event subscription.

SYNTAX
    Unregister-Event [-SubscriptionId] <int> [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]

    Unregister-Event [-SourceIdentifier] <string> [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Unregister-Event cmdlet cancels an event subscription that was created by using the Register-EngineEvent, Register-ObjectEvent, or Register-WmiEvent cmdlet.

    When an event subscription is canceled, the event subscriber is deleted from the session and the subscribed events are no longer added to the event queue. When you cancel a subscription to an event created by using the New-Event cmdlet, the new event is also deleted from the session.

    Unregister-Event does not delete events from the event queue. To delete events, use the Remove-Event cmdlet.

PARAMETERS
    -Force [<SwitchParameter>]
        Cancels all event subscriptions, including subscriptions that were hidden by using the SupportEvent parameter of Register-ObjectEvent, Register-WmiEvent, and Register-EngineEvent.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -SourceIdentifier <string>
        Cancels event subscriptions that have the specified source identifier.

        A SourceIdentifier or SubscriptionId parameter must be included in every command.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -SubscriptionId <int>
        Cancels event subscriptions that have the specified subscription identifier.

        A SourceIdentifier or SubscriptionId parameter must be included in every command.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Management.Automation.PSEventSubscriber
        You can pipe the output from Get-EventSubscriber to Unregister-Event.

OUTPUTS
    None
        This cmdlet does not return any output.

NOTES

        Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.

        Unregister-Event cannot delete events created by using the New-Event cmdlet unless you have subscribed to the event by using the Register-EngineEvent cmdlet. To delete a custom event from the session, you must remove it programmatically or close the session.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Unregister-Event -SourceIdentifier ProcessStarted

    Description
    ———–
    This command cancels the event subscription that has a source identifier of “ProcessStarted”.

    To find the source identifier of an event, use the Get-Event cmdlet. To find the source identifier of an event subscription, use the Get-EventSubscriber cmdlet.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Unregister-Event -subscriptionId 2

    Description
    ———–
    This command cancels the event subscription that has a subscription identifier of 2.

    To find the subscription identifier of an event subscription, use the Get-EventSubscriber cmdlet.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-Eventsubscriber -Force | Unregister-Event -Force

    Description
    ———–
    This command cancels all event subscriptions in the session.

    The command uses the Get-EventSubscriber cmdlet to get all event subscriber objects in the session, including the subscribers that are hidden by using the SupportEvent parameter of the event registration cmdlets.

    It uses a pipeline operator (|) to send the subscriber objects to Unregister-Event, which deletes them from the session. To complete the task, the Force parameter is also required on Unregister-Event.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135269
    Register-ObjectEvent
    Register-EngineEvent
    Register-WmiEvent
    Unregister-Event
    Get-Event
    New-Event
    Remove-Event
    Wait-Event
    Get-EventSubscriber

Unregister-PSSessionConfiguration

NAME
    Unregister-PSSessionConfiguration

SYNOPSIS
    Deletes registered session configurations from the computer.

SYNTAX
    Unregister-PSSessionConfiguration [-Name] <string> [-Force] [-NoServiceRestart] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Unregister-PSSessionConfiguration cmdlet deletes registered session configurations from the computer. This is an advanced cmdlet that is designed to be used by system administrators to manage customized session configurations for their users.

    If you accidentally delete the default Microsoft.PowerShell or Microsoft.PowerShell32 session configurations, use the Enable-PSRemoting cmdlet to restore them.

PARAMETERS
    -Force [<SwitchParameter>]
        Suppresses all user prompts, and restarts the WinRM service without prompting. Restarting the service makes the configuration change effective.

        To prevent a restart and suppress the restart prompt, use the NoServiceRestart parameter.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Name <string>
        Specifies the names of session configurations to delete. Enter one or more configuration names. Wildcards are permitted. This parameter is required.

        You can also pipe a session configuration object to Unregister-PSSessionConfiguration.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -NoServiceRestart [<SwitchParameter>]
        Does not restart the WinRM service, and suppresses the prompt to restart the service.

        By default, when you enter an Unregister-PSSessionConfiguration command, you are prompted to restart the WinRM service to make the change effective. Until the WinRM service is restarted, users can still use the unregistered session configuration, even though Get-PSSessionConfiguration does not find it.

        To restart the WinRM service without prompting, use the Force parameter. To restart the WinRM service manually, use the Restart-Service cmdlet.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration
        You can pipe a session configuration object from Get-PSSessionConfiguration to Unregister-PSSessionConfiguration.

OUTPUTS
    None
        This cmdlet does not return any objects.

NOTES

        To run this cmdlet on Windows Vista, Windows Server 2008, and later versions of Windows, you must start Windows PowerShell with the “Run as administrator” option.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Unregister-PSSessionConfiguration -Name MaintenanceShell

    Description
    ———–
    This command deletes the MaintenanceShell session configuration from the computer.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Unregister-PSSessionConfiguration -maintenanceShell -Force

    Description
    ———–
    This command deletes the MaintenanceShell session configuration from the computer. The command uses the Force parameter to suppress all user messages and to restart the WinRM service without prompting.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Unregister-PSSessionConfiguration -Name *

    C:\PS> Get-PSSessionConfiguration -Name * | Unregister-PSSessionConfiguration

    Description
    ———–
    These commands delete all of the session configurations on the computer. The commands have the same effect and can be used interchangeably.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Unregister-PSSessionConfiguration -Name maintenanceShell -NoServiceRestart

    C:\PS> Get-PSSessionConfiguration -Name maintenanceShell

    Get-PSSessionConfiguration -Name maintenanceShell : No Session Configuration matches criteria “maintenanceShell”.
        + CategoryInfo         : NotSpecified: (:) [Write-Error], WriteErrorException
        + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

    C:\PS> New-PSSession -configurationName MaintenanceShell

     Id Name     ComputerName    State    Configuration         Availability
     — —-     ————    —–    ————-         ————
     1 Session1 localhost     Opened MaintenanceShell     Available

    C:\PS> Restart-Service winrm

    C:\PS> New-PSSession -configurationName MaintenanceShell
    [localhost] Connecting to remote server failed with the following error message : The WS-Management service cannot process the request. The resource
    URI (http://schemas.microsoft.com/powershell/MaintenanceShell) was not found in the WS-Management catalog. The catalog contains the metadata that describes resour
    ces, or logical endpoints. For more information, see the about_remote_TroubleShooting Help topic.
        + CategoryInfo         : OpenError: (System.Manageme….RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
        + FullyQualifiedErrorId : PSSessionOpenFailed

    Description
    ———–
    This example shows the effect of using the NoServiceRestart parameter of Unregister-PSSessionConfiguration. This parameter is designed to prevent a service restart, which would disrupt any sessions on the computer.

    The first command uses the Unregister-PSSessionConfiguration cmdlet to deletes the MaintenanceShell session configuration. However, because the command uses the NoServiceRestart parameter, the WinRM service is not restarted and the change is not yet completely effective.

    The second command uses the Get-PSSessionConfiguration cmdlet to get the MaintenanceShell session. Because the session has been removed from the WS-Management resource table, Get-PSSession cannot return it.

    The third command uses the New-PSSession cmdlet to create a session on the local computer that uses the MaintenanceShell configuration. The command succeeds.

    The fourth command uses the Restart-Service cmdlet to restart the WinRM service.

    The fifth command again uses the New-PSSession cmdlet to create a session that uses the MaintenanceShell configuration. This time, the session fails because the MaintenanceShell configuration has been deleted.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=144308
    about_Session_Configurations
    Disable-PSSessionConfiguration
    Enable-PSSessionConfiguration
    Get-PSSessionConfiguration
    Register-PSSessionConfiguration
    Set-PSSessionConfiguration
    WS-Management Provider

Update-FormatData

NAME
    Update-FormatData

SYNOPSIS
    Updates the formatting data in the current session.

SYNTAX
    Update-FormatData [[-AppendPath] <string[]>] [-PrependPath <string[]>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Update-FormatData cmdlet reloads the formatting data from formatting files into the current session. This cmdlet lets you update the formatting data without restarting Windows PowerShell.

    Without parameters, Update-FormatData reloads the formatting files that it loaded previously. You can use the parameters of Update-FormatData to add new formatting files to the session.

    Formatting files are text files in XML format with the format.ps1xml file name extension. The formatting data in the files defines the display of Microsoft .NET Framework objects in the session.

    When Windows PowerShell starts, it loads the format data from the formatting files in the Windows PowerShell installation directory ($pshome) into the session. You can use Update-FormatData to reload the formatting data into the current session without restarting Windows PowerShell. This is useful when you have added or changed a formatting file, but do not want to interrupt the session.

    For more information about formatting files in Windows PowerShell, see about_Format.ps1xml.

PARAMETERS
    -AppendPath <string[]>
        Adds the specified formatting files to the session. The files are loaded after Windows PowerShell loads the built-in formatting files.

        When formatting .NET objects, Windows PowerShell uses the first formatting definition that it finds for each .NET type. If you use the AppendPath parameter, Windows PowerShell searches the data from the built-in files before it encounters the formatting data that you are adding.

        Use this parameter to add a file that formats a .NET object that is not referenced in the built-in formatting files.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        Accept wildcard characters? false

    -PrependPath <string[]>
        Adds the specified formatting files to the session. The files are loaded before Windows PowerShell loads the built-in formatting files.

        When formatting .NET objects, Windows PowerShell uses the first formatting definition that it finds for each .NET type. If you use the PrependPath parameter, Windows PowerShell searches the data from the files that you are adding before it encounters the formatting data from the built-in files.

        Use this parameter to add a file that formats a .NET object that is also referenced in the built-in formatting files.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains the append path to Update-FormatData.

OUTPUTS
    None
        The cmdlet does not return any output.

NOTES

        Update-FormatData also updates the formatting data for commands in the session that were imported from modules. If the formatting file for a module changes, you can run an Update-FormatData command to update the formatting data for imported commands. You do not need to import the module again.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Update-FormatData

    Description
    ———–
    This command reloads the formatting files that it loaded previously.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Update-FormatData -AppendPath trace.format.ps1xml, log.format.ps1xml

    Description
    ———–
    This command reloads the formatting files into the session, including two new files, Trace.format.ps1xml and Log.format.ps1xml.

    Because the command uses the AppendPath parameter, the formatting data in the new files is loaded after the formatting data from the built-in files.

    The AppendPath parameter is used because the new files contain formatting data for objects that are not referenced in the built-in files.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Update-FormatData -PrependPath c:\test\NewFiles.format.ps1xml

    # Edit the NewFiles.format.ps1 file.

    C:\PS> Update-FormatData

    Description
    ———–
    This example shows how to reload a formatting file after you have edited it.

    The first command adds the NewFiles.format.ps1xml file to the session. It uses the PrependPath parameter because the file contains formatting data for objects that are referenced in the built-in files.

    After adding the NewFiles.format.ps1xml file and testing it in these session, the author edits the file.

    The second command uses the Update-FormatData cmdlet to reload the formatting files. Because the NewFiles.format.ps1xml file was previously loaded, Update-FormatData automatically reloads it without using parameters.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113420

Stop-Service

NAME
    Stop-Service

SYNOPSIS
    Stops one or more running services.

SYNTAX
    Stop-Service [-Name] <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Stop-Service -DisplayName <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Stop-Service [-InputObject <ServiceController[]>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Stop-Service cmdlet sends a stop message to the Windows Service Controller for each of the specified services. You can specify the services by their service names or display names, or you can use the InputObject parameter to pass a service object representing the services that you want to stop.

PARAMETERS
    -DisplayName <string[]>
        Specifies the display names of the services to be stopped. Wildcards are permitted.

        Required?                    true
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Exclude <string[]>
        Omits the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Force [<SwitchParameter>]
        Allows the cmdlet to stop a service even if that service has dependent services.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Include <string[]>
        Stops only the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -InputObject <ServiceController[]>
        Specifies ServiceController objects representing the services to be stopped. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the service names of the services to be stopped. Wildcards are permitted.

        The parameter name is optional. You can use “Name” or its Alias, “ServiceName”, or you can omit the parameter name.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns an object representing the service. By default, this cmdlet does not generate any output.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.ServiceProcess.ServiceController or System.String
        You can pipe a service object or a string that contains the name of a service to Stop-Service.

OUTPUTS
    None or System.ServiceProcess.ServiceController
        When you use the PassThru parameter, Stop-Service generates a System.ServiceProcess.ServiceController object representing the service. Otherwise, this cmdlet does not generate any output.

NOTES

        You can also refer to Stop-Service by its built-in Alias, “spsv”. For more information, see about_aliases.

        Stop-Service can control services only when the current user has permission to do so. If a command does not work correctly, you might not have the required permissions.

        To find the service names and display names of the services on your system, type “Get-Service“. The service names appear in the Name column and the display names appear in the DisplayName column.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Stop-Service sysmonlog

    Description
    ———–
    This command stops the Performance Logs and Alerts (SysmonLog) service on the local computer.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Get-Service -displayname telnet | Stop-Service

    Description
    ———–
    This command stops the Telnet service on the local computer. The command uses the Get-Service cmdlet to get an object representing the Telnet service. The pipeline operator (|) pipes the object to the Stop-Service cmdlet, which stops the service.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-Service iisadmin | Format-List -property name, dependentservices

    C:PS>Stop-Service iisadmin -Force -Confirm

    Description
    ———–
    The Stop-Service command stops the IISAdmin service on the local computer. Because stopping this service also stops the services that depend on the IISAdmin service, it is best to precede the Stop-Service command with a command that lists the services that depend on the IISAdmin service.

    The first command lists the services that depend on IISAdmin. It uses the Get-Service cmdlet to get an object representing the IISAdmin service. The pipeline operator (|) passes the result to the Format-List cmdlet. The command uses the Property parameter of Format-List to list only the Name and DependentServices properties of the service.

    The second command stops the IISAdmin service. The Force parameter is required to stop a service that has dependent services. The command uses the Confirm parameter to request confirmation from the user before stopping each service.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113414
    Get-Service
    Suspend-Service
    Start-Service
    Restart-Service
    Resume-Service
    Set-Service
    New-Service

Suspend-Service

NAME
    Suspend-Service

SYNOPSIS
    Suspends (pauses) one or more running services.

SYNTAX
    Suspend-Service [-Name] <string[]> [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Suspend-Service -DisplayName <string[]> [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Suspend-Service [-InputObject <ServiceController[]>] [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Suspend-Service cmdlet sends a suspend message to the Windows Service Controller for each of the specified services. While suspended, the service is still running, but its action is halted until resumed, such as by using Resume-Service. You can specify the services by their service names or display names, or you can use the InputObject parameter to pass a service object representing the services that you want to suspend.

PARAMETERS
    -DisplayName <string[]>
        Specifies the display names of the services to be suspended. Wildcards are permitted.

        Required?                    true
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Exclude <string[]>
        Omits the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Include <string[]>
        Suspends only the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -InputObject <ServiceController[]>
        Specifies ServiceController objects representing the services to be suspended. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the service names of the services to be suspended. Wildcards are permitted.

        The parameter name is optional. You can use “Name” or its Alias, “ServiceName”, or you can omit the parameter name.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns an object representing the service. By default, this cmdlet does not generate any output.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.ServiceProcess.ServiceController or System.String
        You can pipe a service object or a string that contains a service name to Suspend-Service.

OUTPUTS
    None or System.ServiceProcess.ServiceController
        When you use the PassThru parameter, Suspend-Service generates a System.ServiceProcess.ServiceController object representing the service. Otherwise, this cmdlet does not generate any output.

NOTES

        Suspend-Service can control services only when the current user has permission to do so. If a command does not work correctly, you might not have the required permissions.

        Also, Suspend-Service can suspend only services that support being suspended and resumed. To determine whether a particular service can be suspended, use the Get-Service cmdlet with the CanPauseAndContinue property. For example, “Get-Service wmi | Format-List name, canpauseandcontinue”. To find all services on the computer that can be suspended, type “Get-Service | Where-Object {$_.canpauseandcontinue -eq “True”}”.

        To find the service names and display names of the services on your system, type “Get-Service“. The service names appear in the Name column, and the display names appear in the DisplayName column.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Suspend-Service -displayname “Telnet”

    Description
    ———–
    This command suspends the Telnet service (Tlntsvr) service on the local computer.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Suspend-Service -Name lanman* -WhatIf

    Description
    ———–
    This command tells what would happen if you suspended the services that have a service name that begins with “lanman”. To suspend the services, rerun the command without the WhatIf parameter.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-Service schedule | Suspend-Service

    Description
    ———–
    This command uses the Get-Service cmdlet to get an object that represents the Task Scheduler (Schedule) service on the computer. The pipeline operator (|) passes the result to the Suspend-Service cmdlet, which suspends the service.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Get-Service | Where-Object {$_.canpauseandcontinue -eq “True”} | Suspend-Service -Confirm

    Description
    ———–
    This command suspends all of the services on the computer that can be suspended. It uses the Get-Service cmdlet to get objects representing the services on the computer. The pipeline operator (|) passes the results to the Where-Object cmdlet, which selects only the services that have a value of “True” for the CanPauseAndContinue property. Another pipeline operator passes the results to the Suspend-Service cmdlet. The Confirm parameter prompts you for confirmation before suspending each of the services.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113416
    Get-Service
    Start-Service
    Stop-Service
    Restart-Service
    Resume-Service
    Set-Service
    New-Service

Test-ComputerSecureChannel

NAME
    Test-ComputerSecureChannel

SYNOPSIS
    Tests and repairs the secure channel between the local computer and its domain.

SYNTAX
    Test-ComputerSecureChannel [-Repair] [-Server <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Test-ComputerSecureChannel cmdlet verifies that the secure channel between the local computer and its domain is working correctly by checking the status of its trust relationships. If a connection fails, you can use the Repair parameter to try to restore it.

    Test-ComputerSecureChannel returns “True” if the secure channel is working correctly and “False” if it is not. This result lets you use the cmdlet in conditional statements in Functions and scripts. To get more detailed test results, use the Verbose parameter.

    This cmdlet works much like NetDom.exe. Both NetDom and Test-ComputerSecureChannel use the NetLogon service to perform the actions.

PARAMETERS
    -Repair [<SwitchParameter>]
        Removes and then rebuilds the secure channel established by the NetLogon service. Use this parameter to try to restore a connection that has failed the test (returned “False”.)

        To use this parameter, the current user must be a member of the Administrators group on the local computer.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Server <string>
        Uses the specified domain controller to run the command. If this parameter is omitted, Test-ComputerSecureChannel selects a default domain controller for the operation.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    System.Boolean
        The cmdlet returns “True” when the connection is working correctly and “False” when it is not.

NOTES

        To run a Test-ComputerSecureChannel command on Windows Vista and later versions of Windows, open Windows PowerShell with the “Run as administrator” option.

        Test-ComputerSecureChannel is implemented by using the I_NetLogonControl2 Function, which controls various aspects of the Netlogon service.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Test-ComputerSecureChannel

    True

    Description
    ———–
    This command tests the secure channel between the local computer and the domain to which it is joined.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Test-ComputerSecureChannel -Server DCName.fabrikam.com

    True

    Description
    ———–
    This command specifies a preferred domain controller for the test.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Test-ComputerSecureChannel -Repair

    True

    Description
    ———–
    This command resets the secure channel between the local computer and its domain.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Test-ComputerSecureChannel -Verbose

    VERBOSE: Performing operation “Test-ComputerSecureChannel” on Target “SERVER01”.
    True
    VERBOSE: “The secure channel between ‘SERVER01’ and ‘net.fabrikam.com’ is alive and working correctly.”

    Description
    ———–
    This command uses the Verbose common parameter to request detailed messages about the operation. For more information about the Verbose parameter, see about_CommonParameters.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Set-Alias tcsc Test-ComputerSecureChannel

    if (!(tcsc))
         {Write-Host “Connection failed. Reconnect and retry.”}
    else { &(.\get-Servers.ps1) }

    Description
    ———–
    This example shows how to use Test-ComputerSecureChannel to test a connection before running a script that requires the connection.

    The first command uses the Set-Alias cmdlet to create an Alias for the cmdlet name. This saves space and prevents typing errors.

    The If statement checks the value that Test-ComputerSecureChannel returns before running a script.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=137749
    Checkpoint-Computer
    Restart-Computer
    Stop-Computer
    Reset-ComputerMachinePassword

Set-Variable

NAME
    Set-Variable

SYNOPSIS
    Sets the value of a Variable. Creates the Variable if one with the requested name does not exist.

SYNTAX
    Set-Variable [-Name] <string[]> [[-Value] <Object>] [-Description <string>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-Option {None | ReadOnly | Constant | Private | AllScope}] [-PassThru] [-Scope <string>] [-Visibility {Public | Private}] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Set-Variable cmdlet assigns a value to a specified Variable or changes the current value. If the Variable does not exist, the cmdlet creates it.

PARAMETERS
    -Description <string>
        Specifies the description of the Variable.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Exclude <string[]>
        Omits the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as “*.txt”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Force [<SwitchParameter>]
        Allows you to create a Variable with the same name as an existing read-only Variable, or to change the value of a read-only Variable.

        By default, you can overwrite a Variable, unless the Variable has an option value of “ReadOnly” or “Constant”. For more information, see the Option parameter.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Include <string[]>
        Changes only the specified items. The value of this parameter qualifies the Name parameter. Enter a name or name pattern, such as “c*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the Variable name.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -Option <ScopedItemOptions>
        Changes the value of the Options property of the Variable. Valid values are:

        — None: Sets no options. (“None” is the default.)

        — ReadOnly: The properties of the Variable cannot be changed, except by using the Force parameter. You can use Remove-Variable to delete the Variable.

        — Constant: The Variable cannot be deleted and its properties cannot be changed. “Constant” is available only when you are creating an Alias. You cannot change the option of an existing Variable to “Constant”.

        — Private: The Variable is available only within the scope specified by the Scope parameter. It is inherited by child scopes.

        — AllScope: The Variable is copied to any new scopes that are created.

        To see the Options property of the Variables, type “Get-Variable| Format-Table -property name, options -autosize”.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns an object representing the new Variable. By default, this cmdlet does not generate any output.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Scope <string>
        Determines the scope of the Variable. Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). “Local” is the default. For more information, see about_scopes.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Value <Object>
        Specifies the value of the Variable.

        Required?                    false
        Position?                    2
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        Accept wildcard characters? false

    -Visibility <SessionStateEntryVisibility>
        Determines whether the Variable is visible outside of the session in which it was created. This parameter is designed for use in scripts and commands that will be delivered to other users.

        Valid values are:

        — Public: The Variable is visible. (“Public” is the default.)
        — Private: The Variable is not visible.

        When a Variable is private, it does not appear in lists of Variables, such as those returned by Get-Variable, or in displays of the Variable: drive. Commands to read or change the value of a private Variable return an error. However, the user can run commands that use a private Variable if the commands were written in the session in which the Variable was defined.

        Required?                    false
        Position?                    named
        Default value                Public
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Object
        You can pipe an object that represents the value of the Variable to Set-Variable.

OUTPUTS
    None or System.Management.Automation.PSVariable
        When you use the PassThru parameter, Set-Variable generates a System.Management.Automation.PSVariable object representing the new or changed Variable. Otherwise, this cmdlet does not generate any output.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>Set-Variable -Name desc -Value “A description”

    C:\PS>Get-Variable -Name desc

    Description
    ———–
    These commands set the value of the “desc” Variable to “A description”, and then get the value of the Variable.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Set-Variable -Name processes -Value (Get-Process) -Option constant -Scope global -Description “All processes” -PassThru | Format-List -property *

    Description
    ———–
    This command creates a global, read-only Variable that contains all processes on the system, and then it displays all properties of the Variable.

    The command uses the Set-Variable cmdlet to create the Variable. It uses the PassThru parameter to create an object representing the new Variable, and it uses the pipeline operator (|) to pass the object to the Format-List cmdlet. It uses the Property parameter of Format-List with a value of all (*) to display all properties of the newly created Variable.

    The value, “(Get-Process)”, is enclosed in parentheses to ensure that it is executed before being stored in the Variable. Otherwise, the Variable contains the words “Get-Process“.

    ————————– EXAMPLE 3 ————————–

    C:\PS># Set-Variable -Name counter -Visibility private

    C:\PS> New-Variable -Name counter -Visibility public -Value 26

    C:\PS> $counter
    26

    C:\PS> Get-Variable c*

    Name Value
    —- —–
    Culture en-US
    ConsoleFileName
    ConfirmPreference High
    CommandLineParameters {}
    Counter 26

    C:\PS> Set-Variable -Name counter -Visibility private

    C:\PS> Get-Variable c*

    Name Value
    —- —–
    Culture en-US
    ConsoleFileName
    ConfirmPreference High
    CommandLineParameters {}

    C:\PS> $counter
    “Cannot access the Variable ‘$counter’ because it is a private Variable

    C:\PS> .\use-counter.ps1
    Commands completed successfully.

    Description
    ———–
    This command shows how to change the visibility of a Variable to “Private”. This Variable can be read and changed by scripts with the required permissions, but it is not visible to the user.

    The sample output shows the difference in the behavior of public and private Variables.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113401
    Get-Variable
    New-Variable
    Remove-Variable
    Clear-Variable

Set-WmiInstance

NAME
    Set-WmiInstance

SYNOPSIS
    Creates or updates an instance of an existing Windows Management Instrumentation (WMI) class.

SYNTAX
    Set-WmiInstance [-Class] <string> [[-Arguments] <hashtable>] [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespace <string>] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

    Set-WmiInstance [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespace <string>] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

    Set-WmiInstance -InputObject <ManagementObject> [-Arguments <hashtable>] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

    Set-WmiInstance -Path <string> [-Arguments <hashtable>] [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespace <string>] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

    Set-WmiInstance [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespace <string>] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

    Set-WmiInstance [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespace <string>] [-AsJob] [-PutType {None | UpdateOnly | CreateOnly | UpdateOrCreate}] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Set-WmiInstance cmdlet creates or updates an instance of an existing WMI class. The created or updated instance is written to the WMI repository.

PARAMETERS
    -Arguments <hashtable>
        Specifies the name of the property to be changed and the new value for that property. The name and value must be in a name-value pair. The name-value pair is passed on the command-line as a hash table. For example:
             -argument @{Setting1=1; Setting2=5; Setting3=”test”}.

        Required?                    false
        Position?                    2
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -AsJob [<SwitchParameter>]
        Runs the command as a background job. Use this parameter to run commands that take a long time to finish.

        When you use the AsJob parameter, the command returns an object that represents the background job and then displays the command prompt. You can continue to work in the session while the job finishes. If Set-WmiObject is used against a remote computer, the job is created on the local computer, and the results from remote computers are automatically returned to the local computer. To manage the job, use the cmdlets that contain the Job noun (the Job cmdlets). To get the job results, use the Receive-Job cmdlet.

        Note: To use this parameter with remote computers, the local and remote computers must be configured for remoting. Additionally, you must start Windows PowerShell by using the “Run as administrator” option in Windows Vista and later versions of Windows,. For more information, see about_remote_requirements.

        For more information about Windows PowerShell background jobs, see about_jobs and about_remote_Jobs.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Authentication <AuthenticationLevel>
        Specifies the authentication level to be used with the WMI connection. Valid values are:

        -1: Unchanged
        0: Default
        1: None (No authentication in performed.)
        2: Connect (Authentication is performed only when the client establishes a relationship with the application.)
        3: Call (Authentication is performed only at the beginning of each call when the application receives the request.)
        4: Packet (Authentication is performed on all the data that is received from the client.)
        5: PacketIntegrity (All the data that is transferred between the client and the application is authenticated and verified.)
        6: PacketPrivacy (The properties of the other authentication levels are used, and all the data is encrypted.)

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Authority <string>
        Specifies the authority to use to authenticate the WMI connection. You can specify standard NTLM or Kerberos authentication. To use NTLM, set the authority setting to ntlmdomain:<DomainName>, where <DomainName> identifies a valid NTLM domain name. To use Kerberos, specify kerberos:<DomainName>\<ServerName>”. You cannot include the authority setting when you connect to the local computer.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Class <string>
        Specifies the name of a WMI class.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -ComputerName <string[]>
        Specifies the computer against which you want to run the management operation. The value can be a fully qualified domain name, a NetBIOS name, or an IP address. Use the local computer name, use localhost, or use a dot (.) to specify the local computer. The local computer is the default. When the remote computer is in a different domain from the user, you must use a fully qualified domain name. You can set the value of this parameter by piping the value to the parameter.

        This parameter does not rely on Windows PowerShell remoting, which uses WS-Management ). You can use the ComputerName parameter of Get-WmiObject even if your computer is not configured to run WS-Management remote commands.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Credential <PSCredential>
        Specifies a user account that has permission to perform this action. The default is the current user. Type a user name, such as “User01”, “Domain01\User01”, or User@Contoso.com. Or, enter a PSCredential object, such as an object that is returned by the Get-Credential cmdlet. When you type a user name, you will be prompted for a password.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -EnableAllPrivileges [<SwitchParameter>]
        Enables all the privileges of the current user before the command makes the WMI call .

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Impersonation <ImpersonationLevel>
        Specifies the impersonation level to use. Valid values are:

        0: Default (Reads the local Registry for the default impersonation level, which is usually set to “3: Impersonate”.)
        1: Anonymous (Hides the credentials of the caller.)
        2: Identify (Allows objects to query the credentials of the caller.)
        3: Impersonate (Allows objects to use the credentials of the caller.)
        4: Delegate (Allows objects to permit other objects to use the credentials of the caller.)

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -InputObject <ManagementObject>
        Specifies a ManagementObject object to use as input. When this parameter is used, all other parameters ,except the Arguments parameter, are ignored.

        Required?                    true
        Position?                    named
        Default value
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Locale <string>
        Specifies the preferred locale for WMI objects. The Locale parameter is specified in an array in the MS_<LCID> format in the preferred order.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Namespace <string>
        When used with the Class parameter, this parameter specifies the WMI repository namespace where the referenced WMI class is located.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Path <string>
        Specifies a WMI object path to the instance that you want to create or update.

        Required?                    true
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -PutType <PutType>
        Indicates whether the WMI instance should be created or updated. Valid values are:

        UpdateOnly: Updates an existing WMI instance.
        CreateOnly: Creates a new WMI instance.
        UpdateOrCreate: Updates the WMI instance if it exists or creates a new instance if an instance does not exist.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -ThrottleLimit <int>
        Allows the user to specify a throttling value for the number of WMI operations that can be executed simultaneously. This parameter is used together with the AsJob parameter. The throttle limit applies only to the current command, not to the session or to the computer.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        This cmdlet does not accept input.

OUTPUTS
    None
        This cmdlet does not generate output.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>Set-WmiInstance -Class Win32_WMISetting -argument @{LoggingLevel=2}

    __GENUS                        : 2
    __CLASS                        : Win32_WMISetting
    __SUPERCLASS                 : CIM_Setting
    __DYNASTY                     : CIM_Setting
    __RELPATH                     : Win32_WMISetting=@
    __PROPERTY_COUNT             : 27
    __DERIVATION                 : {CIM_Setting}
    __SERVER                     : SYSTEM01
    __NAMESPACE                    : root\cimv2
    __PATH                         : \\SYSTEM01\root\cimv2:Win32_WMISetting=@
    ASPScriptDefaultNamespace     : \\root\cimv2
    ASPScriptEnabled             : False
    AutorecoverMofs                : {%windir%\system32\wbem\cimwin32.mof, %windir%\system32\wbem\ncprov.mof, %windir%\syst
                                     em32\wbem\wmipcima.mof, %windir%\system32\wbem\secrcw32.mof…}
    AutoStartWin9X                 :
    BackupInterval                 :
    BackupLastTime                 :
    BuildVersion                 : 6001.18000
    Caption                        :
    DatabaseDirectory             : C:\Windows\system32\wbem\repository
    DatabaseMaxSize                :
    Description                    :
    EnableAnonWin9xConnections     :
    EnableEvents                 : False
    EnableStartupHeapPreallocation : False
    HighThresholdOnClientObjects :
    HighThresholdOnEvents         : 20000000
    InstallationDirectory         : C:\Windows\system32\wbem
    LastStartupHeapPreallocation :
    LoggingDirectory             : C:\Windows\system32\wbem\Logs\
    LoggingLevel                 : 2
    LowThresholdOnClientObjects    :
    LowThresholdOnEvents         : 10000000
    MaxLogFileSize                 : 65536
    MaxWaitOnClientObjects         :
    MaxWaitOnEvents                : 2000
    MofSelfInstallDirectory        :
    SettingID                     :

    Description
    ———–
    This command sets the WMI logging level to 2. The command passes the property to be set and the value (together considered a value pair) in the argument parameter. The parameter takes a hash table that is defined by the @{property = value} construction. Theclass information that is returned reflects the new value.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Set-WmiInstance -Class win32_environment -argument @{Name=”testvar”;VariableValue=”testvalue”;UserName=”<SYSTEM>”}

    __GENUS         : 2
    __CLASS         : Win32_Environment
    __SUPERCLASS     : CIM_SystemResource
    __DYNASTY        : CIM_ManagedSystemElement
    __RELPATH        : Win32_Environment.Name=”testvar”,UserName=”<SYSTEM>”
    __PROPERTY_COUNT : 8
    __DERIVATION     : {CIM_SystemResource, CIM_LogicalElement, CIM_ManagedSystemElement}
    __SERVER         : SYSTEM01
    __NAMESPACE     : root\cimv2
    __PATH         : \\SYSTEM01\root\cimv2:Win32_Environment.Name=”testvar”,UserName=”<SYSTEM>”
    Caption         : <SYSTEM>\testvar
    Description     : <SYSTEM>\testvar
    InstallDate     :
    Name             : testvar
    Status         : OK
    SystemVariable : True
    UserName         : <SYSTEM>
    VariableValue    : testvalue

    Description
    ———–
    This command creates the testvar Environment Variable that has the value “testvalue”. It does this by creating a new instance of the Win32_Environment WMI class. Note that this operation requires appropriate credentials and that you may need to restart Windows PowerShell to see the new Environment Variable.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Set-WmiInstance -Class Win32_WMISetting -argument @{LoggingLevel=2} -ComputerName system01, system02, system03

    __GENUS                        : 2
    __CLASS                        : Win32_WMISetting
    __SUPERCLASS                 : CIM_Setting
    __DYNASTY                     : CIM_Setting
    __RELPATH                     : Win32_WMISetting=@
    __PROPERTY_COUNT             : 27
    __DERIVATION                 : {CIM_Setting}
    __SERVER                     : SYSTEM01
    __NAMESPACE                    : root\cimv2
    __PATH                         : \\SYSTEM01\root\cimv2:Win32_WMISetting=@
    ASPScriptDefaultNamespace     : \\root\cimv2
    ASPScriptEnabled             : False
    AutorecoverMofs                : {%windir%\system32\wbem\cimwin32.mof, %windir%\system32\wbem\ncprov.mof, %windir%\syst
                                     em32\wbem\wmipcima.mof, %windir%\system32\wbem\secrcw32.mof…}
    AutoStartWin9X                 :
    BackupInterval                 :
    BackupLastTime                 :
    BuildVersion                 : 6001.18000
    Caption                        :
    DatabaseDirectory             : C:\Windows\system32\wbem\repository
    DatabaseMaxSize                :
    Description                    :
    EnableAnonWin9xConnections     :
    EnableEvents                 : False
    EnableStartupHeapPreallocation : False
    HighThresholdOnClientObjects :
    HighThresholdOnEvents         : 20000000
    InstallationDirectory         : C:\Windows\system32\wbem
    LastStartupHeapPreallocation :
    LoggingDirectory             : C:\Windows\system32\wbem\Logs\
    LoggingLevel                 : 2
    LowThresholdOnClientObjects    :
    LowThresholdOnEvents         : 10000000
    MaxLogFileSize                 : 65536
    MaxWaitOnClientObjects         :
    MaxWaitOnEvents                : 2000
    MofSelfInstallDirectory        :
    SettingID                     :

    …

    Description
    ———–
    This command sets the WMI logging level to 2. The command passes the property to be set and the value (together considered a value pair) in the argument parameter. The parameter takes a hash table that is defined by the @{property = value} construction. The returned class information reflects the new value.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113402
    Get-WmiObject
    Invoke-WmiMethod
    Remove-WmiObject
    Get-WSManInstance
    Invoke-WSManAction
    New-WSManInstance
    Remove-WSManInstance