Skip to content

Commit 522fb20

Browse files
committed
Adding section on PnP PowerShell issue
1 parent b69c362 commit 522fb20

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

articles/automation/troubleshoot/runbooks.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ When you have errors executing runbooks in Azure Automation, you can use the fol
2424

2525
2. **Investigate runbook** [error streams](https://docs.microsoft.com/azure/automation/automation-runbook-output-and-messages#runbook-output) for specific messages and compare them to the errors below.
2626

27-
3. **Ensure your Nodes and Automation workspace have the required modules:** If your runbook imports any modules, ensure they are available to your Automation Account using the steps listed in [Import Modules](../shared-resources/modules.md#import-modules). Update your modules to the latest version by following the instructions at [Update Azure modules in Azure Automation](..//automation-update-azure-modules.md). For more troubleshooting information, see [Troubleshoot Modules](shared-resources.md#modules).
27+
3. **Ensure your Nodes and Automation workspace have the required modules:** If your runbook imports any modules, ensure they are available to your Automation account using the steps listed in [Import Modules](../shared-resources/modules.md#import-modules). Update your modules to the latest version by following the instructions at [Update Azure modules in Azure Automation](..//automation-update-azure-modules.md). For more troubleshooting information, see [Troubleshoot Modules](shared-resources.md#modules).
2828

2929
If your Runbook is suspended or unexpectedly failed:
3030

@@ -59,12 +59,12 @@ If you're trying to access resources in another subscription, you can follow the
5959

6060
1. Go to the Automation Run As account and copy the Application ID and thumbprint.
6161
![Copy Application ID and Thumbprint](../media/troubleshoot-runbooks/collect-app-id.png)
62-
1. Go to the subscription's Access Control where the Automation Account is NOT hosted, and add a new role assignment.
62+
1. Go to the subscription's Access Control where the Automation account is NOT hosted, and add a new role assignment.
6363
![Access control](../media/troubleshoot-runbooks/access-control.png)
6464
1. Add the Application ID you collected in the previous step. Select Contributor permissions.
6565
![Add role assignment](../media/troubleshoot-runbooks/add-role-assignment.png)
6666
1. Copy the name of the subscription for the next step.
67-
1. You can now use the following runbook code to test the permissions from your Automation Account to the other subscription.
67+
1. You can now use the following runbook code to test the permissions from your Automation account to the other subscription.
6868

6969
Replace the "\<CertificateThumbprint\>" with the value you copied in step #1 and the "\<SubscriptionName\>" value you copied in step #4.
7070

@@ -183,7 +183,7 @@ This error can be caused by using outdated Azure modules.
183183

184184
This error can be resolved by updating your Azure modules to the latest version.
185185

186-
In your Automation Account, click **Modules**, and click **Update Azure modules**. The update takes roughly 15 minutes, once complete rerun the runbook that was failing. To learn more about updating your modules, see [Update Azure modules in Azure Automation](../automation-update-azure-modules.md).
186+
In your Automation account, click **Modules**, and click **Update Azure modules**. The update takes roughly 15 minutes, once complete rerun the runbook that was failing. To learn more about updating your modules, see [Update Azure modules in Azure Automation](../automation-update-azure-modules.md).
187187

188188
## <a name="runbook-auth-failure"></a>Scenario: Runbooks fail when dealing with multiple subscriptions
189189

@@ -240,16 +240,16 @@ The term 'Connect-AzureRmAccount' is not recognized as the name of a cmdlet, fun
240240

241241
This error can happen because of the following reasons:
242242

243-
* The module containing the cmdlet isn't imported into the Automation Account.
243+
* The module containing the cmdlet isn't imported into the Automation account.
244244
* The module containing the cmdlet is imported but is out of date.
245245

246246
### Resolution
247247

248248
This error can be resolved by completing one of the following tasks:
249249

250-
If the module is an Azure module, see [How to update Azure PowerShell modules in Azure Automation](../automation-update-azure-modules.md) to learn how to update your modules in your Automation Account.
250+
If the module is an Azure module, see [How to update Azure PowerShell modules in Azure Automation](../automation-update-azure-modules.md) to learn how to update your modules in your Automation account.
251251

252-
If it's a separate module, make sure the module in imported in your Automation Account.
252+
If it's a separate module, make sure the module in imported in your Automation account.
253253

254254
## <a name="job-attempted-3-times"></a>Scenario: The runbook job start was attempted three times, but failed to start each time
255255

@@ -281,7 +281,7 @@ This error occurs due to one of the following issues.
281281

282282
* Module Incompatible. Update your Azure modules by following the steps in [How to update Azure PowerShell modules in Azure Automation](../automation-update-azure-modules.md).
283283

284-
* No Authentication with ADAL for Sandbox. When authenticating to Azure AD with a runbook, ensure that the Azure AD module is available in your Automation Account. Be sure to grant the Run As account the necessary permissions to perform the tasks that the runbook automates.
284+
* No Authentication with ADAL for Sandbox. When authenticating to Azure AD with a runbook, ensure that the Azure AD module is available in your Automation account. Be sure to grant the Run As account the necessary permissions to perform the tasks that the runbook automates.
285285

286286
If your runbook can't call an executable or subprocess running in an Azure sandbox, use the runbook on a [Hybrid Runbook Worker](../automation-hrw-run-runbooks.md). Hybrid workers aren't limited by the memory and network limits that Azure sandboxes have.
287287

@@ -429,7 +429,7 @@ This error occurs when the job execution exceeds the 500-minute free quota for y
429429
If you want to use more than 500 minutes of processing per month, you need to change your subscription from the Free tier to the Basic tier. You can upgrade to the Basic tier by taking the following steps:
430430

431431
1. Sign in to your Azure subscription.
432-
2. Select the Automation Account to upgrade.
432+
2. Select the Automation account to upgrade.
433433
3. Click **Settings**, then **Pricing**.
434434
4. Click **Enable** on page bottom to upgrade your account to the **Basic** tier.
435435

@@ -452,7 +452,7 @@ This error is caused when the PowerShell engine can't find the cmdlet you're usi
452452
Any of the following solutions fix the problem:
453453

454454
* Check that you've entered the cmdlet name correctly.
455-
* Make sure the cmdlet exists in your Automation Account and that there are no conflicts. To verify if the cmdlet is present, open a runbook in edit mode and search for the cmdlet you want to find in the library or run `Get-Command <CommandName>`. Once you've validated that the cmdlet is available to the account, and that there are no name conflicts with other cmdlets or runbooks, add it to the canvas and make sure that you're using a valid parameter set in your runbook.
455+
* Make sure the cmdlet exists in your Automation account and that there are no conflicts. To verify if the cmdlet is present, open a runbook in edit mode and search for the cmdlet you want to find in the library or run `Get-Command <CommandName>`. Once you've validated that the cmdlet is available to the account, and that there are no name conflicts with other cmdlets or runbooks, add it to the canvas and make sure that you're using a valid parameter set in your runbook.
456456
* If you do have a name conflict and the cmdlet is available in two different modules, you can resolve this issue by using the fully qualified name for the cmdlet. For example, you can use **ModuleName\CmdletName**.
457457
* If you're executing the runbook on-premises in a hybrid worker group, then make sure that the module and cmdlet is installed on the machine that hosts the hybrid worker.
458458

@@ -564,6 +564,30 @@ The nxautomationuser account for the Log Analytics agent for Linux is not correc
564564

565565
* Verify the configuration of the nxautomationuser account in the sudoers file. See [Running runbooks on a Hybrid Runbook Worker](../automation-hrw-run-runbooks.md)
566566

567+
## Scenario: Cmdlet failing in PnP PowerShell runbook on Azure Automation
568+
569+
### Issue
570+
571+
When a runbook writes a PnP PowerShell-generated object to the Azure Automation output directly, cmdlet output can't stream back to Automation.
572+
573+
### Cause
574+
575+
This issue is most commonly caused when Azure Automation processes runbooks that invoke PnP PowerShell cmdlets, for example, **add-pnplistitem**, without catching the return objects.
576+
577+
### Resolution
578+
579+
Edit your scripts to assign any return values to variables so that the cmdlets do not attempt to write whole objects to the standard output. A script can redirect the output stream to a cmdlet as shown below.
580+
581+
```azurecli
582+
$null = add-pnplistitem
583+
```
584+
If your script parses cmdlet output, the script must store the output in a variable and manipulate the variable instead of simply streaming the output.
585+
586+
```azurecli
587+
$SomeVariable = add-pnplistitem ....
588+
if ($SomeVariable.someproperty -eq ....
589+
```
590+
567591
## <a name="other"></a>My problem isn't listed above
568592

569593
The sections below list other common errors in addition to supporting documentation to help you resolve your issue.
@@ -587,7 +611,7 @@ For help with passing parameters into webhooks, see [Start a runbook from a webh
587611

588612
## Issues using Az modules
589613

590-
Using Az modules and AzureRM modules in the same Automation Account is not supported. For more information, see [Az modules in runbooks](https://docs.microsoft.com/azure/automation/az-modules) for more details.
614+
Using Az modules and AzureRM modules in the same Automation account is not supported. For more information, see [Az modules in runbooks](https://docs.microsoft.com/azure/automation/az-modules) for more details.
591615

592616
## Inconsistent behavior in runbooks
593617

@@ -608,7 +632,7 @@ For help with passing parameters into webhooks, see [Start a runbook from a webh
608632

609633
## Using Az modules
610634

611-
Using Az modules and AzureRM modules in the same Automation Account is not supported. See [Az modules in runbooks](https://docs.microsoft.com/azure/automation/az-modules).
635+
Using Az modules and AzureRM modules in the same Automation account is not supported. See [Az modules in runbooks](https://docs.microsoft.com/azure/automation/az-modules).
612636

613637
## Using self-signed certificates
614638

0 commit comments

Comments
 (0)