none
whether I can Import-csv to Set-ItemProperty for MDTDeploymentShare RRS feed

  • Question

  • Hi Scripting Guys!

      When i Managing MDT Using Windows PowerShelli to config the  Property of  MDT Deployment Shares

    i wondered if exit another way like looping  a structured csv file and pipeline  command  to Set-ItemProperty to accomplish this task 

    although it departure the object itself and deal with someone  like a text file  but i want a try And it's  similar to other scene

    Here is my code and screenshot 
    Get-ItemProperty "DeploymentShare1:"
    Get-ItemProperty  "DeploymentShare1:" | Out-File $env:HOMEPATH\DeploymentShare1_ItemProperty.csv
    Get-Content $env:HOMEPATH\DeploymentShare1_ItemProperty.csv | % {Write-Host  ($_).Split(':')[0]  ($_).Split(':')[1]  }
    Get-Content C:\Users\Administrator\DeploymentShare1_ItemProperty.csv | % {Set-ItemProperty "DeploymentShare1:" -Name "($_).Split(':')[0]" -Value "($_).Split(':')[1]" -Verbose }
    

    Thursday, June 25, 2020 2:03 AM

Answers

  • You still need to sue Export and Import and you need to learn how to get properties in PowerShell.

    Here is a good place to start.

    As asked your question cannot be answered.  You cannot get a property using just a simple string as the name.  You need to use a registry key path or set the path.

    To create a custom output for a CSV you need to learn to use a custom object.  Learning PowerShell will teach you how to do all of these basic things.

    Unfortunately your question is impossible to understand.  You need to elarn enough about PowerShell to ask a question that makes sense.

    To get a property into a CSV with its name seems to be what you are trying to say.

    Example:

    (Get-ItemProperty HKLM:\software\microsoft\.NETFramework).InstallRoot |
        Select @{n='Property';e={'InstallRoot'}},@{n='InstallRoot';e={$_}} |
        Export-Csv <yourfile> -NoTypeInformation -Append


    \_(ツ)_/

    • Marked as answer by badacook Thursday, June 25, 2020 8:51 AM
    Thursday, June 25, 2020 7:57 AM

All replies

  • help Export-Csv -online

    help Import-Csv -online


    \_(ツ)_/

    Thursday, June 25, 2020 3:08 AM
  • Hi jrv

      You have just looked the title of my question , i know about Export-Csv so i use Out-File command to get a  multi-row .csv file

    each row means a ItemProperty name and its value ,so i want to loop each row and use the ':' symbol as the separator to get each ItemProperty name and its value

    but it didn't  work all my conflict is in the loop

    Thursday, June 25, 2020 7:21 AM
  • You still need to sue Export and Import and you need to learn how to get properties in PowerShell.

    Here is a good place to start.

    As asked your question cannot be answered.  You cannot get a property using just a simple string as the name.  You need to use a registry key path or set the path.

    To create a custom output for a CSV you need to learn to use a custom object.  Learning PowerShell will teach you how to do all of these basic things.

    Unfortunately your question is impossible to understand.  You need to elarn enough about PowerShell to ask a question that makes sense.

    To get a property into a CSV with its name seems to be what you are trying to say.

    Example:

    (Get-ItemProperty HKLM:\software\microsoft\.NETFramework).InstallRoot |
        Select @{n='Property';e={'InstallRoot'}},@{n='InstallRoot';e={$_}} |
        Export-Csv <yourfile> -NoTypeInformation -Append


    \_(ツ)_/

    • Marked as answer by badacook Thursday, June 25, 2020 8:51 AM
    Thursday, June 25, 2020 7:57 AM
  • Thanks very much jrv 

    Thursday, June 25, 2020 8:49 AM
  • Thanks very much jrv 

    Thursday, June 25, 2020 8:51 AM