locked
Update Subnet description with Olddescription+Newdescription value RRS feed

  • Question

  • Hi Expert,

    i having 10k Subnet need to move from old site to NewSite, i have the script below but how to update the new description by retaining the old description value.

    Something like 10.139.216.0/23,Newsite,Olddescription+Newdescription  

    #.\changesite.csv
    #Name,Site,Description
    #10.139.216.0/23,NweSite,NewDescription
    
    Import-csv -path .\changesite.csv | 
    ForEach-Object {
    set-ADReplicationSubnet -Identity $_.Name -site $_.site -Description $_.Description -verbose} 

    Thursday, September 6, 2018 10:03 AM

Answers

  • Just validated the Get-ADReplicationSubnet cmdlet and figured that you need to specify the "Description" property to be returned using the -properties switch.

    Use:

    $current = Get-ADReplicationSubnet -Identity $_.Name -Properties Description

    Does this work?

    • Marked as answer by Kt, Thursday, September 6, 2018 6:16 PM
    Thursday, September 6, 2018 2:27 PM
  • is working now, thanks

    Import-csv -path .\changesite.csv | 
    ForEach-Object {
    $current = Get-ADReplicationSubnet -Identity $_.Name -Properties Description
    Set-ADReplicationSubnet -Identity $_.Name -site $_.site -Description "$($current.Description) $($_.Description)" -verbose}

    • Marked as answer by Kt, Thursday, September 6, 2018 6:16 PM
    Thursday, September 6, 2018 6:16 PM

All replies

  • Or make it easy all the value on Newdescription is same, i only need to retain the Oldvalue+Newvalue

    example:

    Original value 10.139.216.0/23,AAAAASite,this is data center

    Original value  10.139.216.0/24,AAAAASite,this is NON-data center

    Original value  10.139.216.0/25,AAAAASite,this is host

    New value 10.139.216.0/23,BBBBBSite,this is data center/ site migrated

    New value 10.139.216.0/24,BBBBBSite,this is NON-data center/ site migrated

    New value 10.139.216.0/25,BBBBBSite,this is host/ site migrated


    Thursday, September 6, 2018 12:12 PM
  • $current = Get-ADReplicationSubnet -Identity $_.Name
    Set-ADReplicationSubnet -Identity $_.Name -site $_.site -Description "$($current.Description) $($_.Description)" -verbose
    should work.
    Thursday, September 6, 2018 1:06 PM
  • not working, still replacing the new description. (Old value gone)
    Import-csv -path .\changesite.csv | 
    ForEach-Object {
    $current = Get-ADReplicationSubnet -Identity $_.Name
    Set-ADReplicationSubnet -Identity $_.Name -site $_.site -Description "$($current.Description) $($_.Description)" -verbose}

    Thursday, September 6, 2018 2:20 PM
  • Just validated the Get-ADReplicationSubnet cmdlet and figured that you need to specify the "Description" property to be returned using the -properties switch.

    Use:

    $current = Get-ADReplicationSubnet -Identity $_.Name -Properties Description

    Does this work?

    • Marked as answer by Kt, Thursday, September 6, 2018 6:16 PM
    Thursday, September 6, 2018 2:27 PM
  • is working now, thanks

    Import-csv -path .\changesite.csv | 
    ForEach-Object {
    $current = Get-ADReplicationSubnet -Identity $_.Name -Properties Description
    Set-ADReplicationSubnet -Identity $_.Name -site $_.site -Description "$($current.Description) $($_.Description)" -verbose}

    • Marked as answer by Kt, Thursday, September 6, 2018 6:16 PM
    Thursday, September 6, 2018 6:16 PM