Skip to content

Commit 824e848

Browse files
authored
Merge pull request #47945 from georgewallace/textualupdate
AzAutomation : updating examples
2 parents a9792e6 + a39425c commit 824e848

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

articles/automation/automation-edit-textual-runbook.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: automation
66
ms.component: process-automation
77
author: georgewallace
88
ms.author: gwallace
9-
ms.date: 04/02/2018
9+
ms.date: 08/01/2018
1010
ms.topic: conceptual
1111
manager: carmonm
1212
---
@@ -58,34 +58,33 @@ Use the following procedure to open a runbook for editing in the textual editor.
5858

5959
## To edit an Azure Automation runbook using Windows PowerShell
6060

61-
To edit a runbook with Windows PowerShell, you use the editor of your choice and save it to a .ps1 file. You can use the [Get-AzureAutomationRunbookDefinition](http://aka.ms/runbookauthor/cmdlet/getazurerunbookdefinition) cmdlet to retrieve the contents of the runbook and then [Set-AzureAutomationRunbookDefinition](http://aka.ms/runbookauthor/cmdlet/setazurerunbookdefinition) cmdlet to replace the existing draft runbook with the modified one.
61+
To edit a runbook with Windows PowerShell, you use the editor of your choice and save it to a .ps1 file. You can use the [Export-AzureRmAutomationRunbook](/powershell/module/AzureRM.Automation/Export-AzureRmAutomationRunbook) cmdlet to retrieve the contents of the runbook and then [Import-AzureRmAutomationRunbook](/powershell/module/AzureRM.Automation/import-azurermautomationrunbook) cmdlet to replace the existing draft runbook with the modified one.
6262

6363
### To Retrieve the Contents of a Runbook Using Windows PowerShell
6464

6565
The following sample commands show how to retrieve the script for a runbook and save it to a script file. In this example, the Draft version is retrieved. It is also possible to retrieve the Published version of the runbook although this version cannot be changed.
6666

6767
```powershell-interactive
68-
$automationAccountName = "MyAutomationAccount"
69-
$runbookName = "Sample-TestRunbook"
70-
$scriptPath = "c:\runbooks\Sample-TestRunbook.ps1"
68+
$resourceGroupName = "MyResourceGroup"
69+
$automationAccountName = "MyAutomatonAccount"
70+
$runbookName = "Hello-World"
71+
$scriptFolder = "c:\runbooks"
7172
72-
$runbookDefinition = Get-AzureAutomationRunbookDefinition -AutomationAccountName $automationAccountName -Name $runbookName -Slot Draft
73-
$runbookContent = $runbookDefinition.Content
74-
75-
Out-File -InputObject $runbookContent -FilePath $scriptPath
73+
Export-AzureRmAutomationRunbook -Name $runbookName -AutomationAccountName $automationAccountName -ResourceGroupName $resourceGroupName -OutputFolder $scriptFolder -Slot Draft
7674
```
7775

7876
### To Change the Contents of a Runbook Using Windows PowerShell
7977

8078
The following sample commands show how to replace the existing contents of a runbook with the contents of a script file. Note that this is the same sample procedure as in [To import a runbook from a script file with Windows PowerShell](automation-creating-importing-runbook.md).
8179

8280
```powershell-interactive
83-
$automationAccountName = "MyAutomationAccount"
84-
$runbookName = "Sample-TestRunbook"
85-
$scriptPath = "c:\runbooks\Sample-TestRunbook.ps1"
81+
$resourceGroupName = "MyResourceGroup"
82+
$automationAccountName = "MyAutomatonAccount"
83+
$runbookName = "Hello-World"
84+
$scriptFolder = "c:\runbooks"
8685
87-
Set-AzureAutomationRunbookDefinition -AutomationAccountName $automationAccountName -Name $runbookName -Path $scriptPath -Overwrite
88-
Publish-AzureAutomationRunbook –AutomationAccountName $automationAccountName –Name $runbookName
86+
Import-AzureRmAutomationRunbook -Path "$scriptfolder\Hello-World.ps1" -Name $runbookName -Type PowerShell -AutomationAccountName $automationAccountName -ResourceGroupName $resourceGroupName -Force
87+
Publish-AzureRmAutomationRunbook -Name $runbookName -AutomationAccountName $automationAccountName -ResourceGroupName $resourceGroupName
8988
```
9089

9190
## Related articles

0 commit comments

Comments
 (0)