Yes you can do this with the MilestonePSTools PowerShell module. A quick and easy way to do it would be to $csv = Import-Csv on your CSV and then enumerate hardware doing foreach ($hw = Get-Hardware) {}
Inside that foreach, you could do $row = $csv | Where-Object Address -eq $hw.Address
Once you have the hardware, you can edit the name with $hw.Name = $row.Name followed by a $hw.Save()
I’m guessing you want to rename the camera channels under the hardware so you could do $camera = $hw | Get-Camera -Channel 0 to grab the first channel. Then rename it the same way.
All in all it’s around 10 lines or less of PowerShell using the following cmdlets…
Connect-ManagementServer
Import-Csv
Get-Hardware
Get-Camera
Thank you. I don’t know what I am doing wrong, but I have never been able to log into the MPSTools. I am sure it’s something simple, but I get stuck on Connect-Management Server aspect…
I reached out to you directly, but I’ll share here as well. I don’t see an error message in your post so I can only guess you’re getting an error because of the execution policy on the machine where the module is being used. If that’s the issue, you should be able to do the following to change the execution policy:
Set-ExecutionPolicy RemoteSigned
I’ll call you in a few. Thanks for reaching out.
For the benefit of other readers, we were able to get this working. And in this case the goal was to make bulk camera name and description changes in a CSV file, then import those changes.
We generated the CSV like so…
Get-Hardware | Where-Object Enabled | Get-Camera | Where-Object Enabled | Select Name, Description, Id | Export-Csv -Path .\cameras.csv -NoTypeInformation
And when the CSV has been updated, those changes will be read in like so…
foreach ($row in Import-Csv -Path .\cameras.csv) {
$camera = Get-Camera -Id $row.Id
$camera.Name = $row.Name
$camera.Description = $row.Description
$camera.Save()
}
@Josh Hendricks (Milestone Systems) is it also possible to also insert the ShortName for each camera using the above script and is there a complete list of all variables for bulk changes ($camera.)
Hi @Dimitri Frey,
Since MilestonePSTools uses our SDK, the properties on objects it returns are typically documented in our MIP SDK docs. For example, here is the documentation for the Camera object: https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_configuration_items_1_1_camera.html
Since my comment two years ago, the Set-VmsCamera cmdlet has been added, so we could re-implement the script above like so…
# Export enabled camera Name, ShortName, Description and Id
Get-Hardware | Get-VmsCamera | Select Name, ShortName, Description, Id | Export-Csv -Path .\cameras.csv -NoTypeInformation
# Import changes from the CSV above. Remove the "-WhatIf" switch to actually make any changes
foreach ($row in Import-Csv .\cameras.csv) {
$camera = Get-VmsCamera -Id $row.Id
$camera | Set-VmsCamera -Name $row.Name -ShortName $row.ShortName -Description $row.Description -WhatIf
}
Hi @Josh Hendricks (Milestone Systems) , would it also be possible to import the camera shortcut number using the above set command. I didn’t find any information in the SDK documentation.
@Josh Hendricks (Milestone Systems) have you been able to look at my request concerning the shortcut number?
I followed the above and was able to update the Camera Name. However, how would I change the hardware name with the same csv import approach