none
Creating New-CMBoundaries from CSV File - SCCM

    Pergunta

  • Creating New-CMBoundaries from CSV File - SCCM

    You can, according to this site and chap, pipe the values from a CSV to the NEW-CMBOUNDARY cmdlet.

    http://www.dexterposh.com/2014/07/powershell-sccm-2012-boundaries.html

    This is the actual video of the working code being ran: https://youtu.be/jjjigfddkm8

    Essentially he just pipes the import-csv c:\file.csv | new-cmboundary
    with 3 values, Name, Type,Value and it works. I've copied this to the T and cannot for love nor money get this to work.Looking at the help for that cmdlet, pipeline input is not accepted. How did he get the pipeline input accepted?

    I cam up with something like this but, not working at all:

    I have a CSV which i have processed subnet information in using CONCAT and some other functions. I have address range boundaries and Sites and want to automate the creation of SCCM IP Address Range boundaries using PowerShell and the CSV file and New-CMBoundary cmdlet. Please See below:

    • Column B is the Site Code

    • Column F Contains the Range e.g. 192.168.1.0-192.168.1.254

    Code so far:

    'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin' Import-Module .\ConfigurationManager.psd1         cd SCC: Get-CMSite                  $subnetranges = import-csv C:\subnets.csv                 $Site = $subnetranges | select -ExpandProperty "Site Code"                 $Range = $subnetranges | select -ExpandProperty "VLAN5 Range" ForEach ($subnet in $subnetranges) { New-CMBoundary -DisplayName $Site -BoundaryType IPRange -Value $Range      }
    

    This obviously isn't quite right, Can you see what I'm trying to do? how do i get each row from the CSV into the respective variable but then enumerate through using the ForEach loop? If that is even the best method.

    Does anyone know how to do this?

    terça-feira, 3 de julho de 2018 15:06

Todas as Respostas

  • Hi Roystonius 

    It looks your varaiables for $site and $range is your problem your are expandnig the properties out side the loops so they all come as one variable.  I also would not use spaces between your titles in a csv but if you do you can just do a foreach loop and then do $subnet."CSV Heading"  below would be with your heading you specified in the above script. 

    cd 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin'
    Import-Module .\ConfigurationManager.psd1         
    cd SCC: 
    Get-CMSite                  
    $subnetranges = import-csv C:\subnets.csv                
    ForEach ($subnet in $subnetranges) { 
    New-CMBoundary -DisplayName $subnet."Site Code"  -BoundaryType IPRange -Value $subnet."VLAN5 Range"    
    }


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.




    terça-feira, 3 de julho de 2018 20:24