# Azure Automation Question...

**URL:** <https://forums.powershell.org/t/azure-automation-question/5585>\
**Category:** PowerShell Help\
**Created:** [January 22, 2016, 2:30am UTC](https://forums.powershell.org/t/azure-automation-question/5585 "2016-01-22T02:30:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven-ayers](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@steven-ayers](https://forums.powershell.org/u/steven-ayers)\
**Post date:** [January 22, 2016, 2:30am UTC](https://forums.powershell.org/t/azure-automation-question/5585/1 "2016-01-22T02:30:55Z")

</div>

Is it possible to make a runbook to make a directory? or return get-process?

I’ve been messing with Azure Automation, DSC seems to be nicely integrated with a GUI, and runbooks seem great for gathering info on my VMs, or spinning them up and down, but can you use it the same way you would use it sitting on a computer on your network to return processes, or create a folder, or to look at the registry?

---

<div class="post-metadata">

**Author:** ![\_timpringle](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/_timpringle/32/276_2.png) [@\_timpringle](https://forums.powershell.org/u/_timpringle)\
**Post date:** [January 22, 2016, 4:53am UTC](https://forums.powershell.org/t/azure-automation-question/5585/2 "2016-01-22T04:53:01Z")

</div>

Hi Steven,

If you’re wanting Azure Automation to actually run things locally on your environment, you need to configure a hybrid worker, to which it can pass the script to be executed locally.

Alternatively, if you’ve vms in azure, you can do the same. You’ll need to do the commands in your scripts to connect to your subscription first, but once you have done that, and validated, you can use pretty much what you want.

---

<div class="post-metadata">

**Author:** ![steven-ayers](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@steven-ayers](https://forums.powershell.org/u/steven-ayers)\
**Post date:** [January 22, 2016, 5:06am UTC](https://forums.powershell.org/t/azure-automation-question/5585/3 "2016-01-22T05:06:26Z")

</div>

Thanks Tim, they’re in azure…

Do you just open a PSSession remotely on the machine?

Obviously, with my local environment I can just do

```
Get-WMIObject -ComputerName PC1.domain.local -class Win32_operatingsystem
```

I tried something similar using -PSComputerName, however it threw an error, the normal ComputerName parameter wasn’t available for me to use judging from intellisense…

---

<div class="post-metadata">

**Author:** ![\_timpringle](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/_timpringle/32/276_2.png) [@\_timpringle](https://forums.powershell.org/u/_timpringle)\
**Post date:** [January 23, 2016, 2:43am UTC](https://forums.powershell.org/t/azure-automation-question/5585/4 "2016-01-23T02:43:35Z")

</div>

You’ll need to setup your certs configuration to authorise connection from Azure Automation to the virtual machine (it uses HTTPS). Maybe take a look at  
Alexandre Brisebois’ article, which will point you in the right direction:

> **[Azure Automation, Remote PowerShell And a Virtual Machine](https://alexandrebrisebois.wordpress.com/2015/08/14/azure-automation-remote-powershell-and-a-virtual-machine/)**
>
> Using Remote PowerShell on Azure When we have hundreds of Virtual Machines to manage, manual tasks just don’t cut it. they’re error prone and can be quite boring to carry out. On Azure,…

cheers,

tim

---

<div class="post-metadata">

**Author:** ![steven-ayers](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@steven-ayers](https://forums.powershell.org/u/steven-ayers)\
**Post date:** [January 24, 2016, 10:15pm UTC](https://forums.powershell.org/t/azure-automation-question/5585/5 "2016-01-24T22:15:05Z")

</div>

Thanks Tim,

Now I gave this a go, and ran into a few errors - I don’t know if you’ve faced this.

I ensured that I ran Enable-PSSRemoting on the VM and got this error:

```
ERROR: [[MY SERVICE NAME].cloudapp.net] Connecting to remote server .cloudapp.net failed with the following error 
message : The server certificate on the destination computer ([MY SERVICE NAME].cloudapp.net:[PUBLIC VM PORT FOR POWERSHELL]) has the following 
errors:    
The SSL certificate is signed by an unknown certificate authority.  
The SSL certificate contains a common name (CN) that does not match the hostname. For more information, see the 
about_Remote_Troubleshooting Help topic.
    + CategoryInfo : OpenError: ([MY SERVICE NAME].cloudapp.net:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : 12175,PSSessionStateBroken
```

I then did some reading and tried to avoid the SSL checks to see what happened, so I amended the workflow slightly to use PSSSessionOptions:

```
InlineScript {         
        Invoke-command -ConnectionUri $Using:uri -credential $Using:admin -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck) -ScriptBlock { 
            
            # This script executes on the remote VM
            New-Item c:\new-file.txt -type file
         
        } 
    }
```

I then received this error:

```
ERROR: [[MY SERVICE NAME].cloudapp.net] Connecting to remote server [MY SERVICE NAME].cloudapp.net failed with the following error 
message : WS-Management cannot process the request. The operation failed because of an HTTP error. The HTTP error 
(12175) is: A security error occurred . For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo : OpenError: ([MY SERVICE NAME].cloudapp.net:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : 12175,PSSessionStateBroken
```

Cert headache urgh.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:43pm UTC](https://forums.powershell.org/t/azure-automation-question/5585/6 "2024-05-16T20:43:03Z")

</div>


