I am in need of serious help! I have been working my hardest on trying to create a PS script that will set-itemproperty for each computer that is listed in a CSV with headers and I have been failing miserably. I have tried to run my code using foreach loops, assigned items to collectionObjects and I have yet to get what I need. I came close with the collectionObjects variable but noticed at the end that it will only set constant values in the csv and not different values per computer. Please don’t bash me as I am still learning and not as advanced as I would like to be.
headers consist of { Status, Name, Hardware, Scope, Duration..) all saved in a .csv file.
#each collectionobject is assigned a header. The goal is to list a set of computers in the .csv or another file(which ever is better) and have the csv file append the changes that are present in each row.
than Invoke-Command -ComputerName $computers -Credential $credential -ScriptBlock {Set-ItemProperty -Path "HKLM:\SYSTEM\path\status -Name "Status -Value $collectionObject.status }
| Name of Computer | Status | Hardware | Scope | Duration |
| Tom | Active | present | full | indefinite |
| Amber | delayed | installed | full | 30 days |
$collectionObject[0].Status
$collectionObject[0].Name
$collectionObject[0].Hardware
$collectionObject[0].Scope
$collectionObject[0].Duration
$collectionObject = Import-Csv -Path .\Desktop\RegistryFields.csv
$servers = “tom”, “amber”
$credential = Get-Credential -Credential #add creds here
Invoke-Command -ComputerName $servers -Credential $credential -ScriptBlock {Set-ItemProperty -Path “HKLM:\SYSTEM\path\Status” -Name “status” -Value $collectionObject.status}