How to сhange IP addresses for subscriptions on particular IP address via CLI on Windows?

Created:

2017-03-17 11:08:53 UTC

Modified:

2017-08-08 13:28:38 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to сhange IP addresses for subscriptions on particular IP address via CLI on Windows?

Applicable to:

  • Plesk for Windows

Question

How to сhange IP addresses for multiple subscriptions on particular IP address via CLI on Windows?

Answer

To change IP addresses for multiple subscriptions on particular IP run the following Power Shell commands :

  1. Create $DB variable with the path to the mysql.exe utility:

    #$DB = "$env:plesk_dir\MySQL\bin\mysql.exe"
    
  2. Create $DBPASS variable with password of admin user

    #$DBPASS = $( -Split ( &"$env:plesk_bin\plesksrvclient.exe" -get -nogui | `echo ))[3] 2>>$output
    
  3. Create C:\list.txt file with domains on the particular IP - X1.X1.X1.X1

    # & "$DB" "-uadmin" "-P8306" $("-p" + $DBPASS) "psa" -Nse "select name from domains as d left join DomainServices as DS on d.id=DS.dom_id left join IpCollections as IPC on DS.ipCollectionId=IPC.id left join IpAddressesCollections as IPAC on IPAC.ipCollectionId=IPC.id left join IP_Addresses as IPA on IPA.id=IPAC.ipAddressId  where d.id in (select object_id from Subscriptions) and DS.type='web' and IPA.ip_address='X1.X1.X1.X1'" > C:\list.txt
    
    • Where X1.X1.X1.X1 is an IP address to be changed.
  4. The following command will read C:\list.txt file with list of domains and assign to them a new IP address - X2.X2.X2.X2

    # Get-Content C:\list.txt | ForEach-Object {plesk bin subscription --update $_ -ip X2.X2.X2.X2 ; Write-Output "$_ - updated"}
    
    • Where X2.X2.X2.X2 is a new IP address to be assigned .
Have more questions? Submit a request
Please sign in to leave a comment.