Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

problem running invoke-command on azure powershell

$
0
0

Hi all,

 

I'm new on powershell scripting.

i need to do a script to start/stop/status windows service (ej Oracle Listener) after/previus poweron/poweroff a VM.

 

the script then i put on the runbook 

########################################################

workflow MyStartAzureVM

{

    Param

    (   

        [Parameter(Mandatory=$true)]

        [String]

        $vmName,       

 

[Parameter(Mandatory=$true)]

        [String]

        $cloudServiceName 

    )

    # Specify Azure Subscription Name

    $subName = 'Enterprise'   

 

    #please enter your own automation user here. See this blog for help: http://www.russellmccloy.com/2014/12/stop-azurevm-using-azure-automation.html

    $cred = Get-AutomationPSCredential -Name "admazure"

 

    Add-AzureAccount -Credential $cred

 

    Select-AzureSubscription -SubscriptionName $subName 

 

    $vm = Get-AzureVM -ServiceName $cloudServiceName -Name $vmName 

 

 

    Write-Output "$vm"

    Write-Output "vm.InstanceStatus"

 

    if ( $vm.InstanceStatus -eq 'StoppedDeallocated' ) {

        Start-AzureVM -ServiceName $vm.ServiceName -Name $vm.Name     

    }

 

    #Verifico listener y si esta bajo lo subo.

 

    Write-Output "flag Antes del get-service"

 

 ###### in here a have the problem ###########   

    #$lst_status = Get-Service -PSComputerName SRVAZUCLK -name OracleOraDB12Home1TNSListenerLISTENER_WOMDB |select Status

 ##################################   

    $lst_status = 'Stopped'

 

    Write-Output "$lst_status"

 

    ###### in here a have the problem ###########   

    if ( $lst_status -eq 'Stopped' ) {

    InlineScript {Invoke-Command -ComputerName SRVAZUCLK  {start-service -name OracleOraDB12Home1TNSListenerLISTENER_WOMDB}}

    }

####################################

     Write-Output "flag despues del invoke"   

}

########################################################

 

 

but i have this error.

 

1/29/2015 4:04:12 PM, Error: [SRVAZUCLK Connecting to remote server SRVAZUCLK failed with the following error message : The WinRM 

client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer 

is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the 

TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts 

list might not be authenticated. You can get more information about that by running the following command: winrm help 

config. For more information, see the about_Remote_Troubleshooting Help topic.

    + CategoryInfo          : OpenError: (SRVAZUCLK:String) [], PSRemotingTransportException

    + FullyQualifiedErrorId : ServerNotTrusted,PSSessionStateBroken

1/29/2015 4:04:12 PM, Output

 

i add the server to the trusted server but i'm steel geting this error.

on the VM SRVAZUCLK azure powershell console

PS C:\> Get-Item WSMan:\localhost\Client\TrustedHosts

 

 

   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client

 

Type            Name                           SourceOfValue   Value

----            ----                           -------------   -----

System.String   TrustedHosts                                   *

 

 

PS C:\>

 

could someone help me please.

 

Regards

Pablo

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles