Our Story

Who we are and how we solve complex IT challenges.

Our Certifications

Microsoft certifications and partnerships validating our technical expertise.

Leadership

Meet the Experienced Leadership Team Driving WME’s Success

Advisory Updates

Expert guidance on Microsoft, security, and compliance developments.

Case Studies

Real-world outcomes from complex Microsoft-focused IT engagements.

Podcast

Podcasts, panels, and interviews where WME leaders share how they help high-growth companies and IT partners scale.

Ebooks

Practical guides on the Microsoft moves you can’t afford to get wrong.

Financial Industry

Secure technology solutions for regulated banks and financial institutions.

Healthcare

Secure Microsoft solutions for compliant, connected, and modern healthcare organizations.

Manufacturing

Cloud and security solutions supporting modern manufacturing operations.

Non-Profit

Cost-efficient Microsoft solutions for mission-driven organizations.

Public Sector

Microsoft-based IT services for secure public sector modernization.

High Tech

Scalable cloud, security, and staffing for fast-growing technology companies.

SMBs

Scalable cloud, security, and staffing for fast-growing technology companies.

Cloud Migration Services

Transition your workloads to the cloud securely for greater scalability and performance.

Data Migration Services

Securely transfer your business data with minimal downtime and maximum integrity.

Application Migration Services

Move your applications seamlessly to modern platforms with minimal business disruption.

Identity & Security Migration Services

Strengthen identity management and security while transitioning to modern Microsoft solutions.

Security Solutions

Protect your business with proactive cybersecurity, compliance, and risk management solutions.

Endpoint Management

Secure, manage, and monitor every device with modern endpoint management solutions.

Licensing Support

Discover the benefits of both CSP and On-premises licensing options and find the best fit for your unique business needs. From cost savings to flexibility, we’ve got you covered.

Power Platform

Unlock the full potential of the Microsoft Power Platform Suite to streamline operations, automate repetitive tasks, and gain real-time insights that drive business growth.

Sharepoint Solutions

Supercharge your business productivity and enhance visibility through our proven SharePoint expertise.

IT Staffing

Connect with skilled IT professionals to strengthen your team and accelerate project delivery.

Accounting & Finance

Connect with experienced accounting and finance professionals to support your business goals.

Copy Files from a Computer to Azure Files Over CMG

December 26, 2020

With many employees now working remote, the situation may arise where you need to copy files from a remote computer to a location where they can be accessed by IT staff. When a computer is not remote, this is usually done by just accessing the computer’s admin share, but this is not always possible when a computer is remote.

This post will detail a method of using the ConfigMgr scripts feature to copy directories to a Azure Files. This post will detail setting up the Azure Files share, and provide a sample script to use to copy the files. You will need ConfigMgr with a CMG setup to complete this post.

Setup Azure Files

First, we need to configure an Azure Files share. Azure Files is a good solution to use since it can be made available from the internet and does not require a domain login. Though using a domain login is possible, I would recommend NOT doing this, and instead use a shared access signature, which you can and should set to expire when not in use.

To create the Azure Files share, you will first need a storage account. If you already have a storage account and want to reuse it, you can proceed to the next section.

  1. In the Azure portal, search for Storage Accounts and open its service.
  2. Click Add.
  3. Select the Subscription and Resource group for your storage account. Give your storage account a name and Location. Leave Performance, Account kind, and Replication as-is.
  1. Click Review + create to create your storage account.

Now that you have your storage account, we need to create the Azure Files share.

  1. Open your storage account and select File shares from the left pane.
  2. Click the add File share button.
  1. Give your file share a Name and set a Quota. I also recommend setting the Tiers to Hot or Cool, as we shouldn’t be actively doing much with these files.
  1. Click Create.

Azure Files is now set up.

Obtain Shared access signature

Now that we have our Azure file share, we need to generate a Shared access signature (SAS). This will allow us to access the file share without the need for domain credentials.

  1. In your storage account, select Shared access signature from the left pane.
  1. Uncheck all boxes under Allowed Services EXCEPT File.
  2. Under Allowed resource types, select Object.
  3. Leave Allowed permissions as-is. Technically you can dial back the permissions here, but that is out of the scope of this post.
  4. Set a Start and expiry date/time. I would suggest not allowing this SAS key for longer than 1 day. Ideally this key would only work for time needed.
  5. Leave the remaining settings as-is and click Generate SAS and connection string.
  1. Copy the SAS token to Notepad (we’ll need it later).

ConfigMgr Script

This process uses ConfigMgr Run Scripts to execute a script on the computer. The computer will go out and download the AZ Copy utility from Microsoft and use this utility to copy up the Documents and Desktop folders for each user on a computer. You can modify the copy part of the script to copy whichever directories you want. Prior to uploading into Azure Files, the script will zip what’s being copied and upload the zip. This is to save bandwidth and consume less storage in Azure.

Here is the script:

Param(
[Parameter(Mandatory=$True)]
[string]$saskey
)

$az_files_url = "https://azsccmfiles.file.core.windows.net/sccmcmgfiles"

$comp_name = $env:COMPUTERNAME
$date = get-date -format yyyy-MM-ddTHH-mm-ss

$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("https://aka.ms/downloadazcopy-v10-windows","$env:SystemRoot\TEMP\azcopy.zip")

Expand-Archive -LiteralPath "$env:SystemRoot\TEMP\azcopy.zip" -DestinationPath "$env:SystemRoot\TEMP\azcopy" -force
$extract_dir = (get-childitem "$env:SystemRoot\TEMP\azcopy").name
$azcopy = "$env:SystemRoot\TEMP\azcopy\" + $extract_dir

cd $azcopy

$user_folders = (get-childitem $env:systemdrive\users | where-object -filterscript {$_.Name -ne "ADMINI~1"}).name

$output_dir = "$env:SystemRoot\TEMP\azcopy\$comp_name-$date"
new-item -type directory $output_dir | out-null

ForEach ($user in $user_folders) {
new-item -type directory "$output_dir\$user-desktop" | out-null
copy-item -path "$env:systemdrive\users\$user\Desktop\*" -destination "$output_dir\$user-desktop" -recurse

new-item -type directory "$output_dir\$user-documents" | out-null
copy-item -path "$env:systemdrive\users\$user\Documents\*" -destination "$output_dir\$user-documents" -recurse
}

$archive_file = "$env:SystemRoot\TEMP\azcopy\$comp_name-$date.zip"
compress-archive -path $output_dir -destinationpath $archive_file

$env:AZCOPY_LOG_LOCATION="$env:SystemRoot\TEMP\azcopy"
$dest_path = $az_files_url + $saskey
$arguement_list_doc = 'copy "' + $archive_file + '" "' + $dest_path + '" --recursive --cap-mbps 20'
start-process -filepath "azcopy.exe" -ArgumentList $arguement_list_doc -wait -windowstyle:hidden

sleep -s 1

cd $env:SystemRoot
remove-item -path $env:SystemRoot\TEMP\azcopy -recurse -force
remove-item -path $env:SystemRoot\TEMP\azcopy.zip -recurse -force

At each launch, the script will prompt you for the SAS key. On line 6, you need to change the az_files_url variable to match your storage account and file share name. Just replace azsccmfiles with the name of your storage account and sccmcmgfiles with the name of the file share. HINT: you can get this entire URL by going to the storage account in Azure, selecting the file share, and clicking Properties.

All you should have to do now is add this as a script in ConfigMgr. Once added, you can execute it against computers that are remote.

Disclaimer

All content provided on this blog is for information purposes only. Windows Management Experts, Inc makes no representation as to accuracy or completeness of any information on this site. Windows Management Experts, Inc will not be liable for any errors or omission in this information nor for the availability of this information. It is highly recommended that you consult one of our technical consultants, should you need any further assistance.

Share:

Facebook
Twitter
LinkedIn

Get Microsoft Updates Before They Cost You Downtime

Retirement dates, licensing changes, and security updates from a Microsoft-exclusive team, sent when they matter, not on a filler schedule.

More Posts

Copilot Cowork: Credit-Based Billing

Until now, Copilot Cowork has been included with M365 Copilot Premium licenses. Now that Cowork has moved out of public preview, Cowork is introducing a ...
Read Full Article
SharePoint OTP Retirement Is Coming in July 2026

SharePoint OTP Retirement Is Coming in July 2026 — What IT Admins Need to Do Before Access Breaks

Starting July 2026, external users who access OneDrive and SharePoint files through legacy SPO OTP links will start receiving access denied — silently, with no ...
Read Full Article
Power Virtual Agents Is Gone. Here's What Replaced It and Why It Matters.

Power Virtual Agents Is Gone. Here’s What Replaced It and Why It Matters.

If someone on your team still calls it “Power Virtual Agents,” they’re working from an outdated map. Microsoft retired the product on November 15, 2023 ...
Read Full Article

Get Microsoft Updates Before They Cost You Downtime

Retirement dates, licensing changes, and security updates from a Microsoft-exclusive team, sent when they matter, not on a filler schedule.
Subscription Form email