Format Issues Exporting from PowerCLI to dr-ip-customizer

By | January 28, 2015

Just a quick post.

I have a large of PowerCLI functions/cmdlets for SRM that I heavily modified from Ben Meadowcraft.

One of the functions/cmdlets that I was working on was a function called Export-VMNetworking.

The output of this function was a CSV file tha could be used as the input to the dr-ip-customizer (I’m trying to mass input IPs).

At first I was doing the following:

The output looked a little funny though, every field was double-quoted:

“VM ID”,”VM Name”,”vCenter Server”,”Adapter ID”,”DNS Domain”,”Net BIOS”,”Primary WINS”,”Secondary WINS”,”IP Address”,”Subnet Mask”,”Gateway(s)”,”IPv6 Address”,”IPv6 Subnet Prefix length”,”IPv6 Gateway(s)”,”DNS Server(s)”,”DNS Suffix(es)”

When I tried to use this as input to dr-ip-customizer, I received this error:

ERROR: Error on line number ‘2’: The Adapter ID field is invalid.

So I figured I need to get rid of the quotes. No problem right?

Instead of using export-csv, I’m using converto-csv, piping that to replace which swaps out the double-quotes, and then out to a file.

When I tried this file I got a panic!

2015-01-28T15:05:24.773-08:00 [04440 panic ‘Default’] –>
–> Panic: Win32 invalid_parameter error
–> Backtrace:
–> backtrace[00] rip 000007fef60ba04a
–> backtrace[01] rip 000007fef5f7f51f
–> backtrace[02] rip 000007fef5f806be
–> backtrace[03] rip 000007fef60d172c
–> backtrace[04] rip 000007fef60d188c
–> backtrace[05] rip 000007fef60c9723
–> backtrace[06] rip 0000000072c652ad
–> backtrace[07] rip 0000000072c65309
–> backtrace[08] rip 00000001400274d2
–> backtrace[09] rip 0000000140051d6f
–> backtrace[10] rip 000000014005e025
–> backtrace[11] rip 000000014005f0e9
–> backtrace[12] rip 000000014005f50e
–> backtrace[13] rip 00000000774659ed
–> backtrace[14] rip 000000007759c541
–>
2015-01-28T15:05:24.789-08:00 [04440 panic ‘Default’] (Log recursion level 2) Wi
n32 invalid_parameter error

—— In-memory logs start ——–
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘Default’] Section for VMware Wor
kstation, pid=4988, version=e.x.p, build=1964825, option=Release
mem> –>
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘Default’] Logging uses fast path
: true
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘Default’] Handling bora/lib logs
with VmaCore facilities
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘Default’] Initialized channel ma
nager
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘Default’] Current working direct
ory: E:\Program Files\VMware\VMware vCenter Site Recovery Manager\bin
mem> 2015-01-28T15:05:24.711-08:00 [04440 verbose ‘Default’] Setting COM threadi
ng model to MTA
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘Default’] ThreadPool windowsStac
kImmediateCommit = true
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘ThreadPool’] Thread pool on asio
: Min Io, Max Io, Min Task, Max Task, Max Concurency: 2, 401, 2, 200, 2147483647

mem> 2015-01-28T15:05:24.711-08:00 [03716 info ‘ThreadPool’] Thread enlisted
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘ThreadPool’] Thread enlisted
mem> 2015-01-28T15:05:24.711-08:00 [03496 info ‘ThreadPool’] Thread enlisted
mem> 2015-01-28T15:05:24.711-08:00 [03280 info ‘ThreadPool’] Thread enlisted
mem> 2015-01-28T15:05:24.711-08:00 [02648 info ‘ThreadPool’] Thread enlisted
mem> 2015-01-28T15:05:24.711-08:00 [04440 info ‘Default’] Vmacore::InitSSL: hand
shakeTimeoutUs = 120000000
mem> 2015-01-28T15:05:24.711-08:00 [04440 error ‘Default’] Win32 invalid_paramet
er: expression=(null), function=(null), file=(null), line=0
mem> 2015-01-28T15:05:24.789-08:00 [04440 panic ‘Default’] (Log recursion level
2) Win32 invalid_parameter error

—— In-memory logs end ——–
2015-01-28T15:05:24.789-08:00 [04440 panic ‘Default’] Section for VMware Worksta
tion, pid=4988, version=e.x.p, build=1964825, option=Release
–>

Didn’t really like that at all

Next thing I tried was to send the example csv (which worked fine) and my csv to a linux machine to look for weird chars.

In VIM, I used the :set command against the two files:

 

dr-ip-customizer-utf8

dr-ip-customizer-utf16le

 

The example file generated by dr-ip-customizer was in the format utf-8

The file I created in PowerCLI was in the format utf-16le

I went to PowerClI and added the -encoding flag:

 

After that change, the file generated is also utf-8. I did check the original file (with the double-quotes) and that was utf-8. I believe the -replace operation converted the encoding to utf-16le.

I hope this helps someone save some time in the future. The PowerCLi functions I have are kind of all over the place (expanded a lot of Ben’s functions to various values for easier reporting) so I’m not sure I’ll release them, but feel free to ping me if you are interested. I haven’t touched any of the new functionality in PowerCLI 5.8/SRM 5.8 yet though.

3 thoughts on “Format Issues Exporting from PowerCLI to dr-ip-customizer

  1. Greg Hatch

    Chris,
    Awesome find — I’m trying automate our own SRM IP customization using a mix of CMD scripts and an Access database to merge details in from DR-IP-CUSTOMIZER and our IPAM DB to fix discrepancies. Would you be willing to share your PowerShell scripts with me? I’d be glad to share my solution — you could just replace tables in the Access DB with your own sources to make it useful.

    Thanks,
    Greg Hatch

    Reply
  2. Chris Post author

    Hey Greg,
    Thanks for the comment.
    When I’ll get in to the office Monday I’ll send it to the email you used.

    My workflow is protected Vms (static) -> pull from vmware tools/else do a wmi call. Destination side is dhcp so that’s hard coded.

    Reply
  3. Mat Banik

    Hi Greg,

    Just came across your article and feel like I tried reinventing the wheel. Would you be willing to share your source with me as well? I would really appreciate it!

    Reply

Leave a Reply to Chris Cancel reply

Your email address will not be published. Required fields are marked *