cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
stuart_white
Engaged Sweeper II
Firstly I shared the folder that assetimages are stored in giving everyone access to it,

"C:\Program Files (x86)\Lansweeper\Website\assetpictures"



I also changed my share permissions of my actions folder giving everyone access to it,

"C:\Program Files (x86)\Lansweeper\Actions"



(I did this as I was getting errors writing and deleting files)

Create a Report with the following SQL,

Select Top 1000000 tblAssets.AssetID As [Asset ID]
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Where tblAssetCustom.Model Like 'vvx201' And tblAssetCustom.State = 1

  • Replace the Highlighted text with the model of the assets you want to update.

  • Now Run the report and Export to csv.

  • Create a new folder in your Actions Folder called CSV

  • Copy the csv file to CSV folder and rename it "ImportImages.csv"

  • Copy the image file to CSV folder and rename it "ImportImage.jpg"

  • Open Up notepad, copy and paste the following code, and save as "MassPictureUpdate.ps1"



<#

Import Multiple Images to lansweeper

Script: MassPictureUpdate.ps1
Author: Stuart White
Date: 11/10/2017

#>

# Vars
$CSVPath = "\\ASSETSYSTEM\Lansweeper$\CSV\ImportImages.csv"
$ImagePath = "\\ASSETSYSTEM\Lansweeper$\CSV\ImportImage.jpg"
$LansweeperDir = "\\ASSETSYSTEM\assetpictures$\"
#Test File Paths - If the Files exist continue else error message
$TestCSV = Test-Path $CSVPath -PathType leaf
$TestImages = Test-Path $ImagePath -PathType leaf

"Test CSV Path = " + $TestCSV + " / Test Image Path = " + $TestImages
if (($TestCSV) -and ($TestImages)){
$ImageExt = [IO.Path]::GetExtension($ImagePath)
$CSV = Import-Csv $CSVPath
$CSV | foreach-object {
$AssetID = $_."Asset ID;"
"The Image for Asset ID " + $AssetID + " has been Imported"
Copy-Item -Path $ImagePath -Destination "$LansweeperDir$AssetID$ImageExt"
}

#CleanUp
Remove-Item $ImagePath
Remove-Item $CSVPath
Read-Host "Press ENTER to continue..."

}else{
"Please Verify you have copied your csv and image file to the Actions\CSV Directory"
Read-Host "Press ENTER to continue..."

}

  • Edit the highlighted directories to your specific Lansweeper Server Shares

  • Copy MassPictureUpdate.ps1 to your Actions Folder

  • Add the following to your Asset Actions within Lansweeper {actionpath}\MassPictureUpdate.ps1


Basically what the code does is just runs through the csv file, copies the image over the the asset images directory renaming it whatever the assetID is. Once it is done both the CSV file and Image File are deleted.

You can change the highlighted directories to something of your own choosing. The reason I have created shares is so that I can run it as an action from the Lansweeper server rather than the specific local machine.

Hope this is helpful, feel free to critique or suggest edits.
0 REPLIES 0