Tag Archives: Server

Test-ComputerSecureChannel

NAME
    Test-ComputerSecureChannel

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

INPUTS
    None
        You cannot pipe input to this cmdlet.

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

NOTES

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

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

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

    C:\PS>Test-ComputerSecureChannel

    True

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

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

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

    True

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

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

    C:\PS>Test-ComputerSecureChannel -Repair

    True

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

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

    C:\PS>Test-ComputerSecureChannel -Verbose

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

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

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

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

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

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

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

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

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

Reset-ComputerMachinePassword

NAME
    Reset-ComputerMachinePassword

SYNOPSIS
    Resets the machine account password for the computer.

SYNTAX
    Reset-ComputerMachinePassword [-Server <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Reset-ComputerMachinePassword cmdlet changes the machine account password that the computers use to authenticate to the domain controllers in the domain. You can use it to reset the password of the local computer.

PARAMETERS
    -Server <string>
        Specifies the name of a domain controller to use when setting the machine account password.

        This parameter is optional. If you omit this parameter, a domain controller is chosen to service the command.

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

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

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

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

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

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

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    None
        This cmdlet does not generate any output.

NOTES

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

    C:\PS>Reset-ComputerMachinePassword

    Description
    ———–
    This command resets the machine password for the local computer. The command runs with the credentials of the current user.

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

    C:\PS>Reset-ComputerMachinePassword -Server DC01

    Description
    ———–
    This command resets the machine password of the local computer using the DC01 domain controller.

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

    C:\PS>Invoke-Command -computername Server01 -scriptblock {Reset-ComputerMachinePassword}

    Description
    ———–
    This command uses the Invoke-Command cmdlet to run a Reset-ComputerMachinePassword command on the Server01 remote computer.

    For more information about remote commands in Windows PowerShell, see about_remote and Invoke-Command.

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

Add-Computer

NAME
    Add-Computer

SYNOPSIS
    Add the local computer to a domain or workgroup.

SYNTAX
    Add-Computer [-DomainName] <string> [-Credential <PSCredential>] [-OUPath <string>] [-Server <string>] [-UnSecure] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Add-Computer [-WorkGroupName] <string> [-Credential <PSCredential>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Add-Computer cmdlet adds the local computer to a domain or workgroup, or moves it from one domain to another. It also creates a domain account if the computer is added to the domain without an account.

    You can use the parameters of this cmdlet to specify an organizational unit (OU) and domain controller or to perform an unsecure join.

    To get the results of the command, use the Verbose and PassThru parameters.

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.

        Required?                    false
        Position?                    named
        Default value                Current User Account Credentials
        Accept pipeline input?     false
        Accept wildcard characters? false

    -DomainName <string>
        Specifies a domain for the computer account. This parameter is required.

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

    -OUPath <string>
        Specifies an organizational unit (OU) for the domain account. Enter the full distinguished name of the OU. The default value is the default OU for machine objects in the domain.

        Required?                    false
        Position?                    named
        Default value                The default OU for machine objects for in the domain
        Accept pipeline input?     false
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns the results of the command. By default, this cmdlet does not generate any output.

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

    -Server <string>
        Specifies the name of a domain controller that adds the computer to the domain. Enter the name in DomainName\ComputerName format. The default is the local computer.

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

    -UnSecure [<SwitchParameter>]
        Performs an unsecure join.

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

    -WorkGroupName <string>
        Specifies the name of a work group for the computer. If you omit this parameter, the computer is joined to a domain.

        Required?                    true
        Position?                    3
        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
        You cannot pipe objects to Add-Computer.

OUTPUTS
    Microsoft.PowerShell.Commands.ComputerChangeInfo
        When you use the PassThru parameter, Add-Computer returns a ComputerChangeInfo object. Otherwise, this cmdlet does not generate any output.

NOTES

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

    C:\PS>Add-Computer -DomainName Domain01; Restart-Computer

    Description
    ———–
    These commands add the local computer to the Domain01 domain using the credentials of the current user.

    The first command adds the computer to the domain. The second command uses the Restart-Computer cmdlet to restart the computer, which completes the join operation. The semi-colon (;) separates the two commands.

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

    C:\PS>Add-Computer -workgroupname WORKGROUP-A

    Description
    ———–
    This command adds the local computer to the Workgroup-A workgroup.

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

    C:\PS>Add-Computer -DomainName Domain01 -Server Domain01\DC01 -PassThru -Verbose

    Description
    ———–
    This command adds the local computer to the Domain01 domain by using the Domain01\DC01 domain controller.

    The command uses the PassThru and Verbose parameters to get detailed information about the results of the command.

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

    C:\PS>Add-Computer -DomainName Domain02 -OUPath OU=testOU,DC=domain,DC=Domain,DC=com

    Description
    ———–
    This command adds the Server01 and Server02 computers to the Domain02 domain. It uses the OUPath command to specify the organization unit for the new accounts.

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

    C:\PS>Add-Computer -DomainName Domain02 -cred Domain02\Admin02 -PassThru

    Description
    ———–
    This command adds the local computer to the Domain02 domain by using the credentials of a domain administrator. The command uses the PassThru parameter to generate a brief report about the results of the command.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135194
    Checkpoint-Computer
    Remove-Computer
    Restart-Computer
    Restore-Computer
    Stop-Computer
    Test-Connection