Skip to content

Instantly share code, notes, and snippets.

@janegilring
Created August 3, 2019 05:17
Show Gist options
  • Save janegilring/87b812bbb1dbfc1035a9d843a1b86f41 to your computer and use it in GitHub Desktop.
Save janegilring/87b812bbb1dbfc1035a9d843a1b86f41 to your computer and use it in GitHub Desktop.
Example of using the AzureFileSyncAgent DSC resource
Configuration HybridFileServer
{
param (
$AzureCredential = (Get-Credential)
)
Import-DscResource -ModuleName xPSDesiredStateConfiguration -ModuleVersion 8.4.0.0
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName PackageManagement -ModuleVersion 1.2.4
Import-DscResource -ModuleName AzureFileSyncAgentDsc -ModuleVersion 1.1.5
Node FS01 {
Service FileSyncService
{
Name = "FileSyncSvc"
State = "Running"
DependsOn = "[Package]FileSync"
}
xRemoteFile FileSyncPackage {
Uri = "https://download.microsoft.com/download/1/8/D/18DC8184-E7E2-45EF-823F-F8A36B9FF240/StorageSyncAgent_V4_WS2019.msi"
DestinationPath = "C:\Windows\Temp\StorageSyncAgent.msi"
}
Package FileSync {
Ensure = "Present"
Path = "C:\Windows\Temp\StorageSyncAgent.msi"
Name = "Storage Sync Agent"
ProductId = "F5EA481D-EECC-4AA8-B62D-108001DA2462"
Arguments = '/quiet'
DependsOn = "[xRemoteFile]FileSyncPackage"
}
PackageManagement AzureRMPowerShellModule {
Name = 'Az'
ProviderName = 'PowerShellGet'
RequiredVersion = '2.5.0'
Source = 'PSGallery'
DependsOn = "[Package]FileSync"
}
AzureFileSyncAgent Registration {
AzureSubscriptionId = 'c0fda861-1234-5678-9ede-fa1908101500'
AzureFileSyncResourceGroup = 'File-Sync-Rg'
AzureFileSyncInstanceName = 'FileSync01'
AzureCredential = $AzureCredential
DependsOn = '[Service]FileSyncService'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment