Category Archives: Set

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

Set-WSManInstance

NAME
    Set-WSManInstance

SYNOPSIS
    Modifies the management information that is related to a resource.

SYNTAX
    Set-WSManInstance [-ApplicationName <string>] [-ComputerName <string>] [-Fragment <string>] [-Port <int>] [-UseSSL] -ResourceURI <Uri> [[-SelectorSet] <hashtable>] [-Authentication <AuthenticationMechanism>] [-Credential <PSCredential>] [-Dialect <Uri>] [-FilePath <File>] [-SessionOption <hashtable>] [-ValueSet <hashtable>] [<CommonParameters>]

    Set-WSManInstance [-ConnectionURI <Uri>] [-Fragment <string>] -ResourceURI <Uri> [[-SelectorSet] <hashtable>] [-Authentication <AuthenticationMechanism>] [-Credential <PSCredential>] [-Dialect <Uri>] [-FilePath <File>] [-SessionOption <hashtable>] [-ValueSet <hashtable>] [<CommonParameters>]

DESCRIPTION
    The Set-WSManInstance cmdlet modifies the management information that is related to a resource.

    This cmdlet uses the WinRM connection/transport layer to modify the information.

PARAMETERS
    -ApplicationName <string>
        Specifies the application name in the connection. The default value of the ApplicationName parameter is “WSMAN”. The complete identifier for the remote endpoint is in the following format:

             <transport>://<server>:<port>/<ApplicationName>

        For example:

             http://server01:8080/WSMAN

        Internet Information Services (IIS), which hosts the session, forwards requests with this endpoint to the specified application. This default setting of “WSMAN” is appropriate for most uses. This parameter is designed to be used when numerous computers establish remote connections to one computer that is running Windows PowerShell. In this case, IIS hosts Web Services for Management (WS-Management ) for efficiency.

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

    -Authentication <AuthenticationMechanism>
        Specifies the authentication mechanism to be used at the server. Possible values are:

        – Basic: Basic is a scheme in which the user name and password are sent in clear text to the server or proxy.
        – Default : Use the authentication method implemented by the WS-Management protocol. This is the default.
        – Digest: Digest is a challenge-response scheme that uses a server-specified data string for the challenge.
        – Kerberos: The client computer and the server mutually authenticate by using Kerberos Certificates.
        – Negotiate: Negotiate is a challenge-response scheme that negotiates with the server or proxy to determine the scheme to use for authentication. For example, this parameter value allows negotiation to determine whether the Kerberos protocol or NTLM is used.
        – CredSSP: Use Credential Security Service Provider (CredSSP) authentication, which allows the user to delegate credentials. This option is designed for commands that run on one remote computer but collect data from or run additional commands on other remote computers.

        Caution: CredSSP delegates the user’s credentials from the local computer to a remote computer. This practice increases the security risk of the remote operation. If the remote computer is compromised, when credentials are passed to it, the credentials can be used to control the network session.

        Required?                    false
        Position?                    named
        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 must be used. You can pipe a value for this parameter to the cmdlet.

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

    -ConnectionURI <Uri>
        Specifies the connection endpoint. The format of this string is:

             <Transport>://<Server>:<Port>/<ApplicationName>

        The following string is a properly formatted value for this parameter:

             http://Server01:8080/WSMAN

        The URI must be fully qualified .

        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@Domain.com”. Or, enter a PSCredential object, such as one 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

    -Dialect <Uri>
        Specifies the dialect to use in the filter predicate. This can be any dialect that is supported by the remote service. The following Aliases can be used for the dialect URI:

        – WQL: http://schemas.microsoft.com/wbem/wsman/1/WQL
        – Selector: http://schemas.microsoft.com/wbem/wsman/1/wsman/SelectorFilter
        – Association: http://schemas.dmtf.org/wbem/wsman/1/cimbinding/associationFilter

        Required?                    false
        Position?                    named
        Default value                http://schemas.microsoft.com/wbem/wsman/1/WQL
        Accept pipeline input?     false
        Accept wildcard characters? false

    -FilePath <File>
        Specifies the path of a file that is used to update a management resource. You specify the management resource by using the ResourceURI parameter and the SelectorSet parameter . For example, the following command uses the FilePath parameter:

        Invoke-WSManAction -action stopservice -ResourceURI wmicimv2/Win32_Service -SelectorSet @{Name=”spooler”} -FilePath:c:\input.xml -Authentication default

        This command calls the StopService method on the Spooler service by using input from a file. The file, Input.xml, contains the following content:

        <p:StopService_INPUT xmlns:p=”http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service”/>

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

    -Fragment <string>
        Specifies a section inside the instance that is to be updated or retrieved for the specified operation. For example, to get the status of a spooler service, specify “-Fragment Status”.

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

    -OptionSet <hashtable>
        Passes a set of switches to a service to modify or refine the nature of the request. These are similar to switches used in command-line shells because they are service specific. Any number of options can be specified.

        The following example demonstrates the syntax that passes the values 1, 2, and 3 for the a, b, and c parameters:

             -OptionSet @{a=1;b=2;c=3}

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

    -Port <int>
        Specifies the port to use when the client connects to the WinRM service. When the transport is HTTP, the default port is 80. When the transport is HTTPS, the default port is 443. When you use HTTPS as the transport, the value of the ComputerName parameter must match the server’s Certificate common name (CN). However, if the SkipCNCheck parameter is specified as part of the SessionOption parameter, then the Certificate common name of the server does not have to match the host name of the server. The SkipCNCheck parameter should be used only for trusted machines.

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

    -ResourceURI <Uri>
        Contains the Uniform Resource Identifier (URI) of the resource class or instance. The URI is used to identify a specific type of resource, such as disks or processes, on a computer.

        A URI consists of a prefix and a path to a resource. For example:

             http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk
             http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_NumericSensor

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

    -SelectorSet <hashtable>
        Specifies a set of value pairs that are used to select particular management resource instances. The SelectorSet parameter is used when more than one instance of the resource exists. The value of the SelectorSet parameter must be a hash table. The following example shows how to enter a value for this parameter:

            -SelectorSet @{Name=”WinRM”;ID=”yyy”}

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

    -SessionOption <hashtable>
        Defines a set of extended options for the WS-Management session. Enter a SessionOption object that you create by using the New-WSManSessionOption cmdlet. For more information about the options that are available, see New-WSManSessionOption.

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

    -UseSSL [<SwitchParameter>]
        Specifies that the Secure Sockets Layer (SSL) protocol should be used to establish a connection to the remote computer. By default, SSL is not used.

        WS-Management encrypts all the Windows PowerShell content that is transmitted over the network. The UseSSL parameter lets you specify the additional protection of HTTPS instead of HTTP. If SSL is not available on the port that is used for the connection and you specify this parameter, the command fails.

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

    -ValueSet <hashtable>
        Specifies a hash table that helps modify a management resource. You specify the management resource by using the ResourceURI parameter and the SelectorSet parameter. The value of the ValueSet parameter must be a hash table.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (ByPropertyName)
        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 any input.

OUTPUTS
    None
        This cmdlet does not generate any output.

NOTES

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

    C:\PS>Set-WSManInstance -ResourceURI winrm/config/listener -SelectorSet @{address=”*”;transport=”https”} -ValueSet @{Enabled=”false”}

    cfg                 : http://schemas.microsoft.com/wbem/wsman/1/config/listener
    xsi                 : http://www.w3.org/2001/XMLSchema-instance
    lang                 : en-US
    Address             : *
    Transport             : HTTPS
    Port                 : 443
    Hostname             :
    Enabled             : false
    URLPrefix             : WSMan
    CertificateThumbprint :
    ListeningOn         : {127.0.0.1, 172.30.168.171, ::1, 2001:4898:0:fff:0:5efe:172.30.168.171…}

    Description
    ———–
    This command disables the https listener on the local computer.

    Important: The ValueSet parameter is case-sensitive when matching the properties specified.

    For example, using the above command.

    This fails:     -ValueSet @{enabled=”False”}

    This succeeds: -ValueSet @{Enabled=”False”}

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

    C:\PS>Set-WSManInstance -ResourceURI winrm/config -ValueSet @{MaxEnvelopeSizekb = “200”}

    cfg                 : http://schemas.microsoft.com/wbem/wsman/1/config
    lang                : en-US
    MaxEnvelopeSizekb : 200
    MaxTimeoutms        : 60000
    MaxBatchItems     : 32000
    MaxProviderRequests : 4294967295
    Client             : Client
    Service             : Service
    Winrs             : Winrs

    Description
    ———–
    This command sets the MaxEnvelopeSizekb value to 200 on the local computer.

    Important: The ValueSet parameter is case-sensitive when matching the properties specified.

    For example, using the above command.

    This fails:     -ValueSet @{MaxEnvelopeSizeKB =”200″}

    This succeeds: -ValueSet @{MaxEnvelopeSizekb =”200″}

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

    C:\PS>Set-WSManInstance -ResourceURI winrm/config/listener -ComputerName SERVER02 -SelectorSet @{address=”*”;transport=”https”} -ValueSet @{Enabled=”false”}

    cfg                 : http://schemas.microsoft.com/wbem/wsman/1/config/listener
    xsi                 : http://www.w3.org/2001/XMLSchema-instance
    lang                 : en-US
    Address             : *
    Transport             : HTTPS
    Port                 : 443
    Hostname             :
    Enabled             : false
    URLPrefix             : WSMan
    CertificateThumbprint :
    ListeningOn         : {127.0.0.1, 172.30.168.172, ::1, 2001:4898:0:fff:0:5efe:172.30.168.172…}

    Description
    ———–
    This command disables the https listener on the remote computer SERVER02.

    Important: The ValueSet parameter is case-sensitive when matching the properties specified.

    For example, using the above command.

    This fails:     -ValueSet @{enabled=”False”}

    This succeeds: -ValueSet @{Enabled=”False”}

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkId=141458
    Connect-WSMan
    Disable-WSManCredSSP
    Disconnect-WSMan
    Enable-WSManCredSSP
    Get-WSManCredSSP
    Get-WSManInstance
    Invoke-WSManAction
    New-WSManInstance
    New-WSManSessionOption
    Remove-WSManInstance
    Set-WSManQuickConfig
    Test-WSMan

Set-WSManQuickConfig

NAME
    Set-WSManQuickConfig

SYNOPSIS
    Configures the local computer for remote management.

SYNTAX
    Set-WSManQuickConfig [-UseSSL] [<CommonParameters>]

DESCRIPTION
    The Set-WSManQuickConfig cmdlet configures the computer to receive Windows PowerShell remote commands that are sent by using the Web Services for Management (WS-Management) technology.

    The cmdlet performs the following:
    1. Checks whether the WinRM service is running. If the WinRM service is not running, the service is started.
    2. Sets the WinRM service startup type to automatic.
    3. Creates a listener to accept requests on any IP address. By default, the transport is HTTP.
    4. Enables a firewall exception for WinRM traffic .

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

PARAMETERS
    -UseSSL [<SwitchParameter>]
        Specifies that the Secure Sockets Layer (SSL) protocol should be used to establish a connnection to the remote computer. By default, SSL is not used.

        WS-Management encrypts all Windows PowerShell content transmitted over the network. The UseSSL parameter lets you specify that the additional protection of using HTTPS instead of HTTP should be used. If you specify this parameter, but SSL is not available on the port used for the connection, the command fails.

        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 any input.

OUTPUTS
    None
        This cmdlet does not generate any output.

NOTES

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

    C:\PS>Set-WSManQuickConfig

    Description
    ———–
    This command sets the required configuration to enable remote management of the local computer. By default, this command creates a WS-Management listener on HTTP.

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

    C:\PS>Set-WSManQuickConfig -UseSSL

    Description
    ———–
    The command sets the required configuration to enable remote management of the local computer. The UseSSL parameter makes the command create a WS-Management listener on HTTPS.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=141463
    Connect-WSMan
    Disable-WSManCredSSP
    Disconnect-WSMan
    Enable-PSRemoting
    Enable-WSManCredSSP
    Get-WSManCredSSP
    Get-WSManInstance
    Invoke-WSManAction
    New-PSSession
    New-WSManInstance
    New-WSManSessionOption
    Test-WSMan

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-Acl

NAME
    Set-Acl

SYNOPSIS
    Changes the security descriptor of a specified resource, such as a file or a Registry key.

SYNTAX
    Set-Acl [-Path] <string[]> [-AclObject] <ObjectSecurity> [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [-Passthru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Set-Acl cmdlet changes the security descriptor of a specified resource, such as a file or a Registry key, to match the values in a security descriptor that you supply.

    To use Set-Acl, use the Path parameter to identify the resource whose security descriptor you want to change, and use the AclObject parameter to supply a security descriptor that has the values you want to apply. Set-Acl uses the value of the AclObject parameter as a model and changes the values in the resource’s security descriptor to match the values in the AclObject parameter.

PARAMETERS
    -AclObject <ObjectSecurity>
        Specifies an ACL with the desired property values. Set-Acl changes the ACL of resource specified by the Path parameter to match the values in the specified security object.

        You can save the output of a Get-Acl command in a Variable and then use the AclObject parameter to pass the Variable, or type a Get-Acl command.

        Required?                    true
        Position?                    2
        Default value
        Accept pipeline input?     true (ByValue)
        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

    -Filter <string>
        Specifies a filter in the provider’s format or language. The value of this parameter qualifies the Path parameter. The syntax of the filter, including the use of wildcards, depends on the provider. Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved.

        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 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

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

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

    -Path <string[]>
        Identifies the resource whose security descriptor you want to change. Enter the path to a resource, such as a path to a file or Registry key. Wildcards are permitted.

        If you pass a security object to Set-Acl (either by using the AclObject parameter or by passing an object from Get-Acl to Set-Acl), and you omit the Path parameter (name and value), Set-Acl uses the path that is included in the security object.

        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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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.Security.AccessControl.ObjectSecurity
        You can pipe a security descriptor to Set-Acl.

OUTPUTS
    None or security object
        By default, Set-Acl does not generate any output. However, if you use the -Passthru parameter, it generates a security object. The type of the security object depends on the type of the resource.

NOTES

        The Set-Acl cmdlet is supported by the Windows PowerShell file system and Registry providers. As such, you can use it to change the security descriptors of files, directories, and Registry keys.

        When specifying multiple values for a parameter, use commas to separate the values. For example, “<parameter-name> <value1>, <value2>”.

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

    C:\PS>$DogACL = Get-Acl c:\dog.txt

    C:\PS>Set-Acl -Path C:\cat.txt -AclObject $DogACL

    Description
    ———–
    These commands copy the values from the security descriptor of the Dog.txt file to the security descriptor of the Cat.txt file. When the commands complete, the security descriptors of the Dog.txt and Cat.txt files are identical.

    The first command uses the Get-Acl cmdlet to get the security descriptor of the Dog.txt file. The assignment operator (=) stores the security descriptor in the value of the $DogACL Variable.

    The second command uses Set-Acl to change the values in the ACL of Cat.txt to the values in $DogACL.

    The value of the Path parameter is the path to the Cat.txt file. The value of the AclObject parameter is the model ACL, in this case, the ACL of Dog.txt as saved in the $DogACL Variable.

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

    C:\PS>Get-Acl c:\dog.txt | Set-Acl -Path C:\cat.txt

    Description
    ———–
    This command is almost the same as the command in the previous example, except that it uses a pipeline operator to send the security descriptor retrieved in a Get-Acl command to a Set-Acl command.

    The first command uses the Get-Acl cmdlet to get the security descriptor of the Dog.txt file. The pipeline operator (|) passes an object that represents the Dog.txt security descriptor to the Set-Acl command.

    The second command uses Set-Acl to apply the security descriptor of Dog.txt to Cat.txt. When the command completes, the ACLs of the Dog.txt and Cat.txt files are identical.

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

    C:\PS>$newACL = Get-Acl file0.txt

    C:\PS>Get-ChildItem c:\temp -recurse -Include *.txt -force | Set-Acl -AclObject $newacl

    Description
    ———–
    These commands apply the security descriptors in the File0.txt file to all text files in the C:\Temp directory and all of its subdirectories.

    The first command gets the security descriptor of the File0.txt file in the current directory and uses the assignment operator (=) to store it in the $newACL Variable.

    The first command in the pipeline uses the Get-ChildItem cmdlet to get all of the text files in the C:\Temp directory. The Recurse parameter extends the command to all subdirectories of C:\temp. The Include parameter limits the files retrieved to those with the “.txt” file name extension. The Force parameter gets hidden files, which would otherwise be excluded. (You cannot use “c:\temp\*.txt”, because the Recurse parameter works on directories, not on files.)

    The pipeline operator (|) sends the objects representing the retrieved files to Set-Acl command, which applies the security descriptor in the AclObject parameter to all of the files in the pipeline.

    In practice, it is best to use the Whatif parameter with all Set-Acl commands that can affect more than one resource. In this case, the second command in the pipeline would be “Set-Acl -AclObject $newacl -WhatIf“. This command lists the files that would be affected by the command. After reviewing the result, you can run the command again without the Whatif parameter.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113389
    Get-Acl

Set-Alias

NAME
    Set-Alias

SYNOPSIS
    Creates or changes an Alias (alternate name) for a cmdlet or other command element in the current Windows PowerShell session.

SYNTAX
    Set-Alias [-Name] <string> [-Value] <string> [-Description <string>] [-Force] [-Option {None | ReadOnly | Constant | Private | AllScope}] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Set-Alias cmdlet creates or changes an Alias (alternate name) for a cmdlet or for a command element, such as a Function, a script, a file, or other executable. You can also use Set-Alias to reassign a current Alias to a new command, or to change any of the properties of an Alias, such as its description. Unless you add the Alias to the Windows PowerShell profile, the changes to an Alias are lost when you exit the session or close Windows PowerShell.

PARAMETERS
    -Description <string>
        Specifies a description of the Alias. You can type any string. If the description includes spaces, enclose it quotation marks.

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

    -Force [<SwitchParameter>]
        Allows the cmdlet to set a read-only Alias. Use the Option parameter to create a read-only Alias. The Force parameter cannot set a constant Alias.

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

    -Name <string>
        Specifies the new Alias. You can use any alphanumeric characters in an Alias, but the first character cannot be a number.

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

    -Option <ScopedItemOptions>
        Sets the value of the Options property of the Alias.

        Valid values are:

        — None: Sets no options. (default)

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

        — Constant: The Alias 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 Alias to Constant.

        — Private: The Alias is available only within the scope specified by the Scope parameter. It is invisible in all other scopes.

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

        To see the Options property of the Aliases, type “Get-Alias | Format-Table -property Name, Definition, Options -autosize”.

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

    -PassThru [<SwitchParameter>]
        Returns an object representing the Alias. 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>
        Specifies the scope in which this Alias is valid. 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 <string>
        Specifies the name of the cmdlet or command element that is being Aliased.

        Required?                    true
        Position?                    2
        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
    None
        You cannot pipe input to this cmdlet.

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

NOTES

        An Alias is an alternate name or nickname for a cmdlet or command element. To run the cmdlet, you can use its full name or any valid Alias. For more information, see about_aliases.

        To create a new Alias, use Set-Alias or New-Alias. To delete an Alias, use Remove-Item.

        A cmdlet can have multiple Aliases, but an Alias can only be associated with one cmdlet at a time. If you use Set-Alias to associate the Alias with a different cmdlet, it is no longer associated with the original cmdlet.

        You can create an Alias for a cmdlet, but you cannot create an Alias for a command with parameters and values. For example, you can create an Alias for Set-Location, but you cannot create an Alias for “Set-Location C:\Windows\System32″. To create an Alias for a command, create a Function that includes the command, and then create an Alias to the Function.

        To save the Aliases from a session and use them in a different session, add the Set-Alias command to your Windows PowerShell profile. Profiles do not exist by default. To create a profile in the path stored in the $profile Variable, type “New-Item -type file -Force $profile”. To see the value of the $profile Variable, type “$profile”.

        You can also save your Aliases by using Export-Alias to copy the Aliases from the session to a file, and then use Import-Alias to add them to the Alias list for a new session.

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

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

    C:\PS>Set-Alias -Name list -Value Get-ChildItem

    Description
    ———–
    This command creates the Alias “list” for the Get-ChildItem cmdlet. After you create the Alias, you can use “list” in place of “Get-ChildItem” at the command line and in scripts.

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

    C:\PS>Set-Alias list Get-Location

    Description
    ———–
    This command associates the Alias “list” with the Get-Location cmdlet. If “list” is an Alias for another cmdlet, this command changes its association so that it now is the Alias only for Get-Location.

    This command uses the same format as the command in the previous example, but it omits the optional parameter names, -Name and -Value. When you omit parameter names, the values of those parameters must appear in the specified order in the command. In this case, the value of -Name (“list”) must be the first parameter and the value of -Value (“Get-Location“) must be the second parameter.

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

    C:\PS>Set-Alias scrub Remove-Item -Option readonly -PassThru | Format-List

    Description
    ———–
    This command associates the Alias “scrub” with the Remove-Item cmdlet. It uses the “ReadOnly” option to prevent the Alias from being deleted or assigned to another cmdlet.

    The PassThru parameter directs Windows PowerShell to pass an object that represents the new Alias through the pipeline to the Format-List cmdlet. If the PassThru parameter were omitted, there would be no output from this cmdlet to display (in a list or otherwise).

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

    C:\PS>Set-Alias np c:\windows\notepad.exe

    Description
    ———–
    This command associates the Alias, “np”, with the executable file for Notepad. After the command completes, to open Notepad from the Windows PowerShell command line, just type “np”.

    This example demonstrates that you can create Aliases for executable files and elements other than cmdlets.

    To make the command more generic, you can use the “Windir” Environment Variable (${env:windir}) to represent the C\Windows directory. The generic version of the command is “Set-Alias np ${env:windir}\notepad.exe”.

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

    C:\PS>function CD32 {Set-Location c:\windows\system32}

    C:\PS>Set-Alias go cd32

    Description
    ———–
    These commands show how to assign an Alias to a command with parameters, or even to a pipeline of many commands.

    You can create an Alias for a cmdlet, but you cannot create an Alias for a command that consists of a cmdlet and its parameters. However, if you place the command in a Function or a script, then you can create a useful Function or script name and you can create one or more Aliases for the Function or script.

    In this example, the user wants to create an Alias for the command “Set-Location c:\windows\system32″, where “Set-Location” is a cmdlet and “C:\Windows\System32” is the value of the Path parameter.

    To do this, the first command creates a Function called “CD32” that contains the Set-Location command.

    The second command creates the Alias “go” for the CD32 Function. Then, to run the Set-Location command, the user can type either “CD32” or “go”.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113390
    Get-Alias
    New-Alias
    Export-Alias
    Import-Alias

Set-AuthenticodeSignature

NAME
    Set-AuthenticodeSignature

SYNOPSIS
    Adds an Authenticode signature to a Windows PowerShell script or other file.

SYNTAX
    Set-AuthenticodeSignature [-FilePath] <string[]> [-Certificate] <X509Certificate2> [-Force] [-HashAlgorithm <string>] [-IncludeChain <string>] [-TimestampServer <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Set-AuthenticodeSignature cmdlet adds an Authenticode signature to any file that supports Subject Interface Package (SIP).

    In a Windows PowerShell script file, the signature takes the form of a block of text that indicates the end of the instructions that are executed in the script. If there is a signature in the file when this cmdlet runs, that signature is removed.

PARAMETERS
    -Certificate <X509Certificate2>
        Specifies the Certificate that will be used to sign the script or file. Enter a Variable that stores an object representing the Certificate or an expression that gets the Certificate.

        To find a Certificate, use Get-PfxCertificate or use the Get-ChildItem cmdlet in the Certificate (Cert:) drive. If the Certificate is not valid or does not have code-signing authority, the command fails.

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

    -FilePath <string[]>
        Specifies the path to a file that is being signed.

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

    -Force [<SwitchParameter>]
        Allows the cmdlet to append a signature to a read-only file. Even using the Force parameter, the cmdlet cannot override security restrictions.

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

    -HashAlgorithm <string>
        Specifies the hashing algorithm that Windows uses to compute the digital signature for the file. The default is SHA1, which is the Windows default hashing algorithm.

        Files that are signed with a different hashing algorithm might not be recognized on other systems.

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

    -IncludeChain <string>
        Determines which Certificates in the Certificate trust chain are included in the digital signature. “NotRoot” is the default.

        Valid values are:

        — Signer: Includes only the signer’s Certificate.

        — NotRoot: Includes all of the Certificates in the Certificate chain, except for the root authority.

        –All: Includes all the Certificates in the Certificate chain.

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

    -TimestampServer <string>
        Uses the specified time stamp server to add a time stamp to the signature. Type the URL of the time stamp server as a string.

        The time stamp represents the exact time that the Certificate was added to the file. A time stamp prevents the script from failing if the Certificate expires because users and programs can verify that the Certificate was valid at the time of signing.

        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 file path to Set-AuthenticodeSignature.

OUTPUTS
    System.Management.Automation.Signature

NOTES

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

    C:\PS>$cert=Get-ChildItem -Path cert:\CurrentUser\my -CodeSigningCert

    C:\PS>Set-AuthenticodeSignature -FilePath PsTestInternet2.ps1 -Certificate $cert

    Description
    ———–
    These commands retrieve a code-signing Certificate from the Windows PowerShell Certificate provider and use it to sign a Windows PowerShell script.

    The first command uses the Get-ChildItem cmdlet and the Windows PowerShell Certificate provider to get the Certificates in the Cert:\CurrentUser\My subdirectory of the Certificate store. (The Cert: drive is the drive exposed by the Certificate provider.) The CodeSigningCert parameter, which is supported only by the Certificate provider, limits the Certificates retrieved to those with code-signing authority. The command stores the result in the $cert Variable.

    The second command uses the Set-AuthenticodeSignature cmdlet to sign the PSTestInternet2.ps1 script. It uses the FilePath parameter to specify the name of the script and the Certificate parameter to specify that the Certificate is stored in the $cert Variable.

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

    C:\PS>$cert = Get-PfxCertificate C:\Test\Mysign.pfx

    C:\PS>Set-AuthenticodeSignature -FilePath ServerProps.ps1 -Cert $cert

    Description
    ———–
    These commands use the Get-PfxCertificate cmdlet to find a code signing Certificate. Then, they use it to sign a Windows PowerShell script.

    The first command uses the Get-PfxCertificate cmdlet to find the C:\Test\MySign.pfx Certificate and store it in the $cert Variable.

    The second command uses Set-AuthenticodeSignature to sign the script. The FilePath parameter of Set-AuthenticodeSignature specifies the path to the script file being signed and the Cert parameter passes the $cert Variable containing the Certificate to Set-AuthenticodeSignature.

    If the Certificate file is password protected, Windows PowerShell prompts you for the password.

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

    C:\PS>Set-AuthenticodeSignature -FilePath c:\scripts\Remodel.ps1 -Certificate $cert -IncludeChain All -TimestampServer “http://timestamp.fabrikam.com/scripts/timstamper.dll”

    Description
    ———–
    This command adds a digital signature that includes the root authority in the trust chain, and it is signed by a third-party timestamp server.

    The command uses the FilePath parameter to specify the script being signed and the Certificate parameter to specify the Certificate that is saved in the $cert Variable. It uses the IncludeChain parameter to include all of the signatures in the trust chain (including the root authority). It also uses the TimeStampServer parameter to add a timestamp to the signature. This prevents the script from failing when the Certificate expires.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113391
    about_Signing
    about_execution_policies
    Get-AuthenticodeSignature
    Get-PfxCertificate
    Get-ExecutionPolicy
    Set-ExecutionPolicy

Set-Content

NAME
    Set-Content

SYNOPSIS
    Writes or replaces the content in an item with new content.

SYNTAX
    Set-Content [-LiteralPath] <string[]> [-Value] <Object[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Set-Content [-Path] <string[]> [-Value] <Object[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Set-Content cmdlet is a string-processing cmdlet that writes or replaces the content in the specified item, such as a file. Whereas the Add-Content cmdlet appends content to a file, Set-Content replaces the existing content. You can type the content in the command or send content through the pipeline to Set-Content.

PARAMETERS
    -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” or “Domain01\User01”, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

        This parameter is not supported by any providers installed with Windows PowerShell

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (ByPropertyName)
        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

    -Filter <string>
        Specifies a filter in the provider’s format or language. The value of this parameter qualifies the Path parameter. The syntax of the filter, including the use of wildcards, depends on the provider. Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved.

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

    -Force [<SwitchParameter>]
        Allows the cmdlet to set the contents of a file, even if the file is read-only. Implementation varies from provider to provider. For more information, see about_providers. Even using the Force parameter, the cmdlet cannot override security restrictions.

        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 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

    -LiteralPath <string[]>
        Specifies the path to the item that will receive the content. Unlike Path, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

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

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

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

    -Path <string[]>
        Specifies the path to the item that will receive the content. Wildcards are permitted.

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

    -Value <Object[]>
        Specifies the new content for the item.

        Required?                    true
        Position?                    2
        Default value
        Accept pipeline input?     true (ByValue, 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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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 contains the new value for the item to Set-Content.

OUTPUTS
    None or System.String
        When you use the Passthru parameter, Set-Content generates a System.String object representing the content. Otherwise, this cmdlet does not generate any output.

NOTES

        You can also refer to Set-Content by its built-in Alias, “sc”. For more information, see about_aliases.

        Set-Content is designed for string processing. If you pipe non-string objects to Set-Content, it converts the object to a string before writing it. To write objects to files, use Out-File.

        The Set-Content cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type “Get-PSProvider“. For more information, see about_providers.

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

    C:\PS>Set-Content -Path C:\Test1\test*.txt -Value “Hello, World”

    Description
    ———–
    This command replaces the contents of all files in the Test1 directory that have names beginning with “test” with “Hello, World”. This example shows how to specify content by typing it in the command.

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

    C:\PS>Get-Date | Set-Content C:\Test1\date.csv

    Description
    ———–
    This command creates a comma-separated Variable-length (csv) file that contains only the current date and time. It uses the Get-Date cmdlet to get the current system date and time. The pipeline operator passes the result to Set-Content, which creates the file and writes the content.

    If the Test1 directory does not exist, the command fails, but if the file does not exist, the command will create it.

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

    C:\PS>(Get-Content Notice.txt) | ForEach-Object {$_ -replace “Warning”, “Caution”} | Set-Content Notice.txt

    Description
    ———–
    This command replaces all instances of “Warning” with “Caution” in the Notice.txt file.

    It uses the Get-Content cmdlet to get the content of Notice.txt. The pipeline operator sends the results to the ForEach-Object cmdlet, which applies the expression to each line of content in Get-Content. The expression uses the “$_” symbol to refer to the current item and the Replace parameter to specify the text to be replaced.

    Another pipeline operator sends the changed content to Set-Content which replaces the text in Notice.txt with the new content.

    The parentheses around the Get-Content command ensure that the Get operation is complete before the Set operation begins. Without them, the command will fail because the two Functions will be trying to access the same file.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113392
    about_providers
    Add-Content
    Get-Content
    Clear-Content

Set-Date

NAME
    Set-Date

SYNOPSIS
    Changes the system time on the computer to a time that you specify.

SYNTAX
    Set-Date [-Adjust] <TimeSpan> [-DisplayHint {Date | Time | DateTime}] [-Confirm] [-WhatIf] [<CommonParameters>]

    Set-Date [-Date] <DateTime> [-DisplayHint {Date | Time | DateTime}] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Set-Date cmdlet changes the system date and time on the computer to a date and time that you specify. You can specify a new date and/or time by typing a string or by passing a DateTime or TimeSpan object to Set-Date. To specify a new date or time, use the Date parameter. To specify a change interval, use the Adjust parameter.

PARAMETERS
    -Adjust <TimeSpan>
        Adds or subtracts the specified value from the current date and time. You can type an adjustment in standard date and time format for your locale or use the Adjust parameter to pass a TimeSpan object from New-TimeSpan to Set-Date.

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

    -Date <DateTime>
        Changes the date and time to the specified values. You can type a new date in the short date format and a time in the standard time format for your locale. Or, you can pass a Date-Time object from Get-Date.

        If you specify a date, but not a time, Set-Date changes the time to midnight on the specified date. If you specify only a time, it does not change the date.

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

    -DisplayHint <DisplayHintType>
        Determines which elements of the date and time are displayed.

        Valid values are:

        — date: displays only the date
        — time: displays only the time
        — datetime: displays the date and time

        This parameter affects only the display. It does not affect the DateTime object that Get-Date retrieves.

        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.DateTime
        You can pipe a date to Set-Date.

OUTPUTS
    System.DateTime
        Set-Date returns an object that represents the date that it set.

NOTES

        Use this cmdlet cautiously. Changing the date and time on the computer. The change might prevent the computer from receiving system-wide events and updates that are triggered by a date or time. Use the -WhatIf and -Confirm parameters to avoid errors.

        You can use standard .NET methods with the DateTime and TimeSpan objects used with Set-Date, such as AddDays, AddMonths and FromFileTime. For more information, see “DateTime Methods” and “TimeSpan Methods.”

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

    C:\PS>Set-Date -Date (Get-Date).AddDays(3)

    Description
    ———–
    This command adds three days to the current system date. It does not affect the time. The command uses the Date parameter to specify the date. It uses the Get-Date cmdlet to get the current date and time and applies the AddDays .NET method for DateTime objects with a value of 3 (days).

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

    C:\PS>Set-Date -adjust -0:10:0 -DisplayHint time

    Description
    ———–
    This command sets the current system time back by 10 minutes. It uses the Adjust parameter to specify an interval of change and the time change (minus ten minutes) in standard time format for the locale. The DisplayHint parameter tells Windows PowerShell to display only the time, but it does not affect the DateTime object that Set-Date returns.

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

    C:\PS>$t = Get-Date

    C:\PS>Set-Date -Date $t

    Description
    ———–
    These commands change the system date and time on the computer to the date and time saved in the Variable $t. The first command gets the date and stores it in $t. The second command uses the Date parameter to pass the DateTime object in $t to the Set-Date cmdlet.

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

    C:\PS>$90mins = New-TimeSpan -minutes 90

    C:\PS>Set-Date -adjust $90mins

    Description
    ———–
    These commands advance the system time on the local computer by 90 minutes. The first command uses the New-TimeSpan cmdlet to create a TimeSpan object with a 90-minute interval, and then it saves the TimeSpan object in the $90mins Variable. The second command uses the Adjust parameter of Set-Date to adjust the date by the value of the TimeSpan object in the $90mins Variable.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113393
    Get-Date
    New-TimeSpan

Set-ExecutionPolicy

NAME
    Set-ExecutionPolicy

SYNOPSIS
    Changes the user preference for the Windows PowerShell execution policy.

SYNTAX
    Set-ExecutionPolicy [-ExecutionPolicy] {Unrestricted | RemoteSigned | AllSigned | Restricted | Default | Bypass | Undefined} [[-Scope] {Process | CurrentUser | LocalMachine | UserPolicy | MachinePolicy}] [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Set-ExecutionPolicy changes the user preference for the Windows PowerShell execution policy.

    To run this command on Windows Vista, Windows Server 2008, and later versions of Windows, you must start Windows PowerShell with the “Run as administrator” option, even if you are a member of the Administrators group on the computer.

    The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including your Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.

    For more information, see about_execution_policies.

PARAMETERS
    -ExecutionPolicy <ExecutionPolicy>
        Specifies a new execution policy for the shell. The parameter name (“Name”) is optional.

        Valid values are:

        — Restricted: Does not load configuration files or run scripts. “Restricted” is the default.

        — AllSigned: Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.

        — RemoteSigned: Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.

        — Unrestricted: Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.

        — Bypass: Nothing is blocked and there are no warnings or prompts.

        — Undefined: Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.

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

    -Force [<SwitchParameter>]
        Suppresses all prompts. By default, Set-ExecutionPolicy displays a warning whenever you change the execution policy.

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

    -Scope <ExecutionPolicyScope>
        Specifies the scope of the execution policy. The default is LocalMachine.

        Valid values are:

        — Process: The execution policy affects only the current Windows PowerShell process.
        — CurrentUser: The execution policy affects only the current user.
        — LocalMachine: The execution policy affects all users of the computer.

        To remove an execution policy from a particular scope, set the execution policy for that scope to Undefined.

        Required?                    false
        Position?                    2
        Default value                LocalMachine
        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
    Microsoft.PowerShell.ExecutionPolicy, System.String
        You can pipe an execution policy object or a string that contains the name of an execution policy to Set-ExecutionPolicy.

OUTPUTS
    None
        This cmdlet does not return any output.

NOTES

        When you use Set-ExecutionPolicy, the new user preference is written to the Registry and remains unchanged until you change it.

        However, if the “Turn on Script Execution” Group Policy is enabled for the computer or user, the user preference is written to the Registry, but it is not effective, and Windows PowerShell displays a message explaining the conflict. You cannot use Set-ExecutionPolicy to override a Group Policy, even if the user preference is more restrictive than the policy.

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

    C:\PS>Set-ExecutionPolicy remotesigned

    Description
    ———–
    This command sets the user preference for the shell execution policy to RemoteSigned.

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

    C:\PS>Set-ExecutionPolicy Restricted

    Set-ExecutionPolicy : Windows PowerShell updated your local preference successfully, but the setting is overridden by the group policy applied to your system. Due to the override, your shell will retain its current effective execution policy of “AllSigned”. Contact your group policy administrator for more information.
    At line:1 char:20
    + Set-ExecutionPolicy <<<< restricted

    Description
    ———–
    This command attempts to set the execution policy for the shell to “Restricted.” The “Restricted” setting is written to the Registry, but because it conflicts with a Group Policy, it is not effective, even though it is more restrictive than the policy.

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

    C:\PS>Invoke-Command -computername Server01 -scriptblock {Get-ExecutionPolicy} | Set-ExecutionPolicy -Force

    Description
    ———–
    This command gets the execution policy from a remote computer and applies that execution policy to the local computer.

    The command uses the Invoke-Command cmdlet to send the command to the remote computer. Because you can pipe an ExecutionPolicy (Microsoft.PowerShell.ExecutionPolicy) object to Set-ExecutionPolicy, the Set-ExecutionPolicy command does not need an ExecutionPolicy parameter.

    The command does have a Force parameter, which suppresses the user prompt.

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

    C:\PS>Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy AllSigned -Force

    C:\PS> Get-ExecutionPolicy -list

            Scope ExecutionPolicy
            —– —————
    MachinePolicy         Undefined
     UserPolicy         Undefined
         Process         Undefined
     CurrentUser         AllSigned
     LocalMachine     RemoteSigned

    C:\PS> Get-ExecutionPolicy
    AllSigned

    Description
    ———–
    This example shows how to set an execution policy for a particular scope.

    The first command uses the Set-ExecutionPolicy cmdlet to set an execution policy of AllSigned for the current user. It uses the Force parameter to suppress the user prompts.

    The second command uses the List parameter of Get-ExecutionPolicy to get the execution policies set in each scope. The results show that the execution policy that is set for the current user differs from the execution policy set for all users of the computer.

    The third command uses the Get-ExecutionPolicy cmdlet without parameters to get the effective execution policy for the current user on the local computer. The result confirms that the execution policy that is set for the current user takes precedence over the one set for all users.

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

    C:\PS>Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Undefined

    Description
    ———–
    This command uses an execution policy value of Undefined to effectively remove the execution policy that is set for the current user scope. As a result, the execution policy that is set in Group Policy or in the LocalMachine (all users) scope is effective.

    If you set the execution policy in all scopes to Undefined and the Group Policy is not set, the default execution policy, Restricted, is effective for all users of the computer.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113394
    Get-ExecutionPolicy
    Set-AuthenticodeSignature
    Get-AuthenticodeSignature
    about_execution_policies
    about_Signing