0

I am using the following script to stop the node on a machine. But getting Getting Stop-NlbClusterNode : A parameter cannot be found that matches parameter name 'Credential'. error while stopping node using power-shell script and windows 2012. Also how can I pass a password in this script. Please guide.

#This script monitors stopped application pools along with websites on the current host
$RemoteHostName = "testserver"
    #set hostname
    #import NLB module.  In PS v3 these lines should be redundant and can be removed.
    import-module NetworkLoadBalancingClusters
    "Networking Load Balancing Clusters Module imported"
    # requests the user's credentials and assigns the credentials to an object
    $Credential = Get-Credential "domain\testuser"
    "Get credentials for test user done"
    #uses the nlb cmdlets to check the state of the current cluster
    $clusterstatus = get-nlbclusternode -nodename $RemoteHostName
    [string]$status = $clusterstatus | select -expand state
    "Got the status of cluster $clusterstatus"
        #if the node has already been stopped dont do anything
    if ($status -eq "Stopped")
        {
            #donothing 
            "Node alrerady stopped"
        }

        #if the node hasnt been stopped, stop the node and then send an email out
    else
        {
        "Starting to drain stop the node"
            stop-NlbClusterNode -HostName $RemoteHostName -Credential $Credential -Drain
        }

start-sleep -s 30

sam
  • 4,594
  • 12
  • 61
  • 111
  • 1
    The `stop-NlbClusterNode` cmdlet, has not a `-credential` parameter: http://technet.microsoft.com/en-us/library/ee817127.aspx – CB. Jun 10 '13 at 10:17
  • yes, you are right this script now works fine on local but how can I get rid of username and password prompt – sam Jun 10 '13 at 10:23
  • removing this line maybe? `$Credential = Get-Credential "domain\testuser"`, but I think I missed your question... – CB. Jun 10 '13 at 10:28
  • If I remove the line you suggested it will give get-nlbclusternode : Access is denied error. Now Problem is how to pass the password in credentials. – sam Jun 10 '13 at 11:21
  • but in your code you don't use `$credential` in `get-nlbclusternode` and this cmdlet doesn't have a `--credential` parameter anyway... You need to run your code from a user with cluster administrative credential – CB. Jun 10 '13 at 11:33
  • thanks for you guidance, the following command does the trick: $Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord – sam Jun 10 '13 at 11:42

0 Answers0