Skip to content

Commit 5baaada

Browse files
authored
Merge pull request #464 from smallstep/josh/ws1-script-new-item-exists
Conditionally call 'New-Item' in WS1 agent script.
2 parents f344789 + 340715c commit 5baaada

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tutorials/connect-workspace-one-to-smallstep.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ Within a few minutes after adding the connection, you should see all of your Wor
7272
3. Use the following snippet as the **Code**, making sure to replace `<team-id>` with the Team ID value you copied from the Smallstep UI earlier.
7373

7474
```xml
75-
New-Item -Path "HKLM:\Software\Policies\Smallstep"
75+
$RegistryPath = "HKLM:\Software\Policies\Smallstep"
76+
77+
If (-NOT (Test-Path $RegistryPath)) {
78+
New-Item -Path $RegistryPath
79+
}
80+
7681
Set-ItemProperty -Path "HKLM:\Software\Policies\Smallstep" -Name "TeamSlug" -Value "<team-id>"
7782
Set-ItemProperty -Path "HKLM:\Software\Policies\Smallstep" -Name "Certificate" -Value "capi:store-location=machine;store=My;issuer=Smallstep (<team-id>) Agents Intermediate CA;cn=$env:DEVICE_ID"
7883
```

0 commit comments

Comments
 (0)