How To Copy Logs From A Windows Device To The Cloud (Azure Blob Storage)

 How To Copy Logs From A Windows Device To The Cloud (Azure Blob Storage)

This method can either be used during a Task Sequence or in the Run Script feature in ConfigMgr/Intune.

Login to your Azure Portal (click here )and search for Storage Accounts and open it. (This blog won't cover on how to create a Storage Account, but will be covered on a later post or if requested)


Choose a Storage Account you would like to use or create a new one. (All Storage Accounts have been blanked out for security reasons)


Click on Containers in the right hand pane




Right Click on 'Blob Containers' and choose 'Create blob container'.   



Give it a name and Click Create.  In this blog, we will call it test-logs


Find the Container by using the Search Box above it.


Right Click on it > Get Shared Signature Access


Set am Expiry Date far in the future, in my case 2061, tick all the Permissions and Click Create.

You will be presented with the URI and Query String for it.  Copy the Query String to be used at a later stage.

Now we are going to copy the required modules from a device that has it installed already to our Azure Blob Storage so that it can be downloaded when ran as Run Script or during a Task Sequence

On your own/VM device, install the module required.  Open Powershell as admin and run the following command

    Install-Module azure.storage -Confirm:$False -Force

Once installed, head over to "C:\Program Files\WindowsPowerShell\Modules" and zip the 2 folders, Azure.Storage and AzureRM.profile.  We will call the zip file AzureModules.zip

Now go to your Azure Blob Storage Container created earlier (test-logs), and click Upload on the top ribbon


Leave everything on default and click upload.  You should see the following



Once the file has been uploaded, Right Click on it and choose 'Get Shared Access Signature' and change the expiry date to a time in the very far future.  Leave everything else as default.

Click Create and Copy the URI



Now to the script part, big thanks to Tom Degreef - https://www.oscc.be/sccm/Logging-in-the-cloud-Part-1/

The script can be downloaded from here .  Just replace the 4 values with your ones and it should be good to go. $url , StorageAccountName , storSas and container

$url is the URI for the Azure-Modules.zip we generate above.
StorageAccountName is the name of the storage account.
StoreSas is the Query String we generated for the container test-logs above.
Container is the name of the container, in our case test-logs

How the first part of the script works?


Basically, it will check if you have the modules installed already.  If you do, it will skip the rest and go to Import the module directly.  If you don't have the modules installed, it will download it from the Azure Blob Storage, unzip it to C:\Program Files\WindowsPowershell\Modules and then import it.

My solution doesn't require any packages to be deployed to the machine beforehand.  It's a one script shop, which will download the modules from the Blob Storage if it doesn't exist.

This solution works with both the Run Script feature in ConfigMgr/Intune and in a Task Sequence.

Add as a script in ConfigMgr

Go to Software Library and click Scripts


Right Click on it > Create Script

Copy Paste the script from my GitHub and following the instructions on screen.  Don't forget to approve the script.

Find the device you want to run the Script on.  Right click on the device > Run Script


Find the script, and click Next twice.  The script will now run on the selected device, and upload the logs to the Blob Storage.  You should see something like this once the upload is done.





That's it for now, until next time.

Comments

  1. Play The Best Slot Games Online - Lucky Club
    Play The Best Slot Games Online with Lucky Club, the home to progressive jackpots, luckyclub.live bingo, blackjack, video poker, live dealer and more!

    ReplyDelete
  2. Casino de Drmcd
    › › 김해 출장샵 Casino De Drmcd · Location & 문경 출장마사지 timings · In addition 김제 출장안마 to 부산광역 출장샵 creating a 청주 출장안마 fun environment, the Casino de Drmcd Hotel & Spa has an outdoor pool. · Health, safety and security

    ReplyDelete

Post a Comment