I have a script that connects to a web service to retrieve customer details for use in configuring a server. Later on in the script it connects to a BITS service to obtain installation files.
Both use New-WebServiceProxy and [ref] variables to export the data:
$cproxy = New-WebServiceProxy -Uri "http://first.domain.com/clientupdatewebservice.asmx" $cproxy.CheckInstallationIdV2($installcode, [ref]$company, [ref]$dnsadd, [ref]$null, [ref]$null, [ref]$null) ... $bproxy = New-WebServiceProxy -Uri http://second.domain.com/rmsdownloadservice.asmx -Credential $cred $bits = New-Object -Type Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1ms_com_downloadservice_asmx.Directory $bproxy.GetLatestVersionDetails([ref]$bits) | Out-Null
This has been running perfectly fine until today, which I now realise is because currently there is no restart between the two sections while previously there was. The error I’m getting is that the type for $bits cannot be found.
If I run the two individually it’s fine, but once the first proxy is created I can’t create the object for $bits (nor does it want to accept anything like PSObject or Object or whatever, it has to be the exact type AFAIK). Disposing the original proxy doesn’t help either.