Download Data from Sharepoint

Copper Contributor

Hello swarmknowledge,
I would like to automate various things with the NinjaOne program.

 

Since we still need a platform from which we can download for software distribution, or rather for the distribution of certain other data, I thought of Sharepoint for everything that is not an .exe or .msi file.

 

I then created a new user in our 365 tenant and uploaded an image file via Teams and then downloaded it via Powershell. (This is my first user experience with Teams/Sharepoint and data upload or download).

 

With this script it seems to work, but the file seems to be downloaded defectively or created on my PC.

Alternatively, I also tried this with my MS user and also with a .zip file and the problem also existed in both cases.

 

Can someone help me with my script and explain where the problem or problems are and what I should pay attention to here?

 

This is the last attempt:

 

# Path of download link
$downloadUrl = Ninja-Property-Docs-get "Hintergrund" url

 

# destinationfolder
$Zielordner = "C:\SCS Install Files\"

 

# credentials
$username = "UserNameMailAdreass"
$password = ConvertTo-SecureString -String "UserPassword" -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password

 

# check destination folder and possible create it
if (!(Test-Path -Path $Zielordner)) {
New-Item -ItemType Directory -Path $Zielordner -Force
}

# download file with credentials
wget "$downloadUrl" -outfile "$Zielordner\Hintergrund.bmp" -Credential $credential -PassThru

 

This is the error message from the .bmp file:

Sebastian_Wenning_0-1715588145202.png

 

 

Thanks in advance and best regards

 

1 Reply
Maybe I have to push this topic?