Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all 6937 articles
Browse latest View live

Remotely Querying a key on all user's registry on multiple machines

$
0
0

basically what I want to do is run a query on all machines within an IP range to find a registry key from each user on each machine, all the machines are on a domain which I have domain admin on

it would be best if I could write these to a .csv file or similar 

this is what i have so far, it's currently running by wildcard on machine name, but that won't get all machines i want and may get some outside of the range I need (192.168.3.0-192.168.3.255)

$server='mex'[a-z0-9]*
$key ='SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings'
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Users', $server)
$regKey = $regKey.OpenSubKey($key)
$p = $regKey.GetValue('ProxyOverride')

I think i can export using this

http://powershell.com/cs/forums/t/16862.aspx


Powershell and Plink

$
0
0

Back again

Being that I am new to powershell; I am trying my best to learn it and to get my first function to work completely.

I have this fuction; it does complete but somewhere I must  have went wrong in my scripting. I want it logon to a switch using plink; I am using the -l, -pw, and -m plink option at least I think I am. Here is what my function script looks lilke:

$SwitchIP = Get-Content C:\Scripts\Brocadeswitch\switchIP.txt
$SwitchLogon = Get-Content C:\Scripts\Brocadeswitch\SwitchLogon.txt
$SwitchPsswd = Get-Content C:\Scripts\Brocadeswitch\Switchpsswd.txt
$SwitchCliCommand = Get-Content C:\Scripts\Brocadeswitch\SwitchCommand.txt
$SwitchLogFile = "C:\Scripts\Brocadeswitch\Brocade-Log-" + (Get-date -f dd ).tostring() + (Get-date -f MM ).tostring() + ((Get-Date).year).tostring() + ".txt"

 

Function Get-SwitchInformation
{
 param(
[string]$SwitchIP,
[string]$SwitchLogon,
[string]$SwitchPsswd,
[string]$SwitchCliCommand
)

(Get-Date) > $SwitchLogFile

$SwitchIP | % { $_ >> $SwitchLogFile ; & C:\Scripts\Brocadeswitch\plink.exe -l $SwitchLogon  -pw $SwitchPsswd  -m . $SwitchCliCommand $_ >> $SwitchLogFile}

}

When I run it I get this output.


Tuesday, April 22, 2014 12:32:05 PM

PuTTY Link: command-line connection utility
Release 0.63
Usage: plink [options] [user@]host [command]
       ("host" can also be a PuTTY saved session name)
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -ssh -telnet -rlogin -raw -serial
            force use of a particular protocol
  -P port   connect to specified port
  -l user   connect with specified username
  -batch    disable all interactive prompts
The following options only apply to SSH connections:
  -pw passw login with specified password
  -D [listen-IP:]listen-port
            Dynamic SOCKS-based port forwarding
  -L [listen-IP:]listen-port:host:port
            Forward local port to remote address
  -R [listen-IP:]listen-port:host:port
            Forward remote port to local address
  -X -x     enable / disable X11 forwarding
  -A -a     enable / disable agent forwarding
  -t -T     enable / disable pty allocation
  -1 -2     force use of particular protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -m file   read remote command(s) from file
  -s        remote command is an SSH subsystem (SSH-2 only)
  -N        don't start a shell/command (SSH-2 only)
  -nc host:port
            open tunnel in place of session (SSH-2 only)
  -sercfg configuration-string (e.g. 19200,8,n,1,X)
            Specify the serial configuration (serial only)

 

not what I was looking for; it was just a basic switch.

Would please tell me a beginner where I am going wrong or a better way to do what I am trying to do.

 

Thanks

 

Exception calling "Add" with "1" argument(s): "This row already belongs to this table."

$
0
0

Good afternoon Powershell.com !

I am trying to automate some paper based processes using Powershell. We already had in place a Powershell solution where the output was an Excel Spreadsheet, but for planning for the future we felt that a CSV output was easier to work with than Excel.

What we are doing is pretty basic, we are reaching out to the owners of groups in AD, specified in a text file. For each group listed, we're looping through and adding the items to the table. Here's the problem, I am still very new to Powershell and am having issues looping through the 'for each' statements cleanly.

I am experiencing the following error:

    Exception calling "Add" with "1" argument(s): "This row already belongs to this table."
    At line:77 char:17
    + $table2.Rows.Add <<<< ($row2)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

I feel it's appropriate to share the code I am working with:

import-module activedirectory
$strGroupList = get-content "C:\Users\MYUSERNAME\Documents\Group Audit\audit.txt"
$strDate = Get-Date

foreach ($strGroup in $strGroupList)
{
$strGroupMember = Get-aduser -Identity $Group -property description
$tabName = "GroupAuditTable"

#Create the Table Object
$table = New-Object system.Data.DataTable "$tabName"
$table2 = New-Object system.Data.DataTable "$tabName2"

#define columns for row 1
$col1 = New-Object system.Data.DataColumn $strGroup,([string])
$col2 = New-Object system.Data.DataColumn $strDate,([string])

#define columns for row 2
$col3 = New-Object system.Data.DataColumn Name,([string])
$col4 = New-Object system.Data.DataColumn Description, ([string])
$col5 = New-Object system.Data.DataColumn NetworkID, ([string])
$col6 = New-Object system.Data.DataColumn Nested, ([string])

#Add the columns to row 1
$table.columns.add($col1)
$table.columns.add($col2)

#Add the columns to row 2
$table2.columns.add($col3)
$table2.columns.add($col4)
$table2.columns.add($col5)
$table2.columns.add($col6)

#create a row
$row = $table.NewRow()
$row2 = $table2.NewRow()

#create an additional row for the titles of columns
$rowTitles = $table.NewRow()
$rowTitles2 = $table2.NewRow()

$strGroupDetails = Get-ADGroupMember -identity $strGroup 
foreach ($Group in $strGroupDetails)
    {
##########################################################################  Check for nested groups        
        if($Group.ObjectClass -eq "group")
        {
        $strGroupDetails = Get-ADGroupMember -identity $Group #-Recursive
        $strNestedGroupName = $Group.name
##########################################################################  List members of nested groups
        foreach($strNestedGroup in $strGroupDetails)
            {
            #$strNestedGroupName = $Group.name
            $strGroupMember = Get-aduser -Identity $StrNestedGroup -property description

            $row2.Name = $strGroupMember.name
            $row2.Description = $strGroupMember.description
            $row2.NetworkID =  $strGroupMember.SamAccountName
            $row2.Nested = "(From NESTED GROUP:  " + $strNestedGroupName
            $table2.Rows.Add($row2)
            }
        }

        else
        {
#enter data into row 2

$row2.Name = $strGroupMember.name
$row2.Description = $strGroupMember.description
$row2.NetworkID =  $strGroupMember.SamAccountName
$row2.Nested = "Not Nested"

#Add the row to the table
$table.Rows.Add($row)

#Add the row to the second table
$table2.Rows.Add($row2)

#Display the table
$table | format-table -AutoSize
$table2 | format-table -AutoSize
}




}

}
$tabCsv = $table | export-csv C:\Users\MYUSERNAME\Desktop\Audit\GroupAudit.csv -noType
$tabCsv2 = $table2 | export-csv C:\Users\MYUSERNAME\Desktop\Audit\GroupAudit_2.csv -noType

That's it, pretty basic stuff.

The error is on line #77:

$table2.Rows.Add($row2)

This worked before I stuck the 'Nested Groups' For Each loop in there, and I am just puzzled as to why that would break it, unless I am missing something obvious here. When I remove this:

foreach ($Group in $strGroupDetails)
    {
##########################################################################  Check for nested groups        
        if($Group.ObjectClass -eq "group")
        {
        $strGroupDetails = Get-ADGroupMember -identity $Group #-Recursive
        $strNestedGroupName = $Group.name
##########################################################################  List members of nested groups
        foreach($strNestedGroup in $strGroupDetails)
            {
            #$strNestedGroupName = $Group.name
            $strGroupMember = Get-aduser -Identity $StrNestedGroup -property description

            $row2.Name = $strGroupMember.name
            $row2.Description = $strGroupMember.description
            $row2.NetworkID =  $strGroupMember.SamAccountName
            $row2.Nested = "(From NESTED GROUP:  " + $strNestedGroupName
            $table2.Rows.Add($row2)
            }
        }

        else
        {
#enter data into row 2

Things work as expected, what am I missing?

Invoke Command not reading a parameter

$
0
0

Hi there

I'm just testing a section of my script whereby i want to eliminate hard coding a version folder and pass something like this

Login credentials are passed in the script from another XML so that logging into the server is not an issue.

$deployversion = "v4"

Write-Host "copied Register.bat to \\$server\e$\$deployversion\Assets\bin\"  

$reg = invoke-command -computername ServerA -ScriptBlock {Set-Location "E:\$deployversion\Assets\bin"; & ".\Register.bat"} -erroraction 'stop' -credential $cred

When i run this script on it's own in PowerGUI script editor, i get message saying unable to find E:\$deployversion\Assets\bin folder on the server. So looks like $deployversion is not getting passed to the invoke command.

please can you advise how to resolve this issue?

Trying to invoke script from two levels up

$
0
0

I need to execute a script that is in a path structure that is two folders up (back) from my current location.  I can not move either script.  I have tried

invoke-expression -command ".\<script name> with params but get an error saying <script name> is not a cmdlet.

can I use ..\..\?  what is the correct format?

Thanks

Get a list a users from a group, then get all of those users group recursive groupmembership

$
0
0

I am stumped on this.. I am close I just cannot figure out how to get the recursive group membership for the list of users

Here is what I am doing, but I have tried this several ways

$group= (get-adgroupmember05225-Recursive).name

foreach ($userin$group) {get-aduser$user-Properties*|Select-Objectname,@{name="MemberOf";expression={$_.memberof }} |Export-CsvC:\temp\lAudit.csv-NoTypeInformation-Append }

This basically gives me a column with the name and the other column with the DN of the groups (I would love to make this the Samaccount name) I tried the following but it didn't work like I wanted.. for one I no longer can have a name column :( just a list a groups for 1110 users..

foreach ($userin$group){ (GET-ADUSER$user–PropertiesMemberOf|Select-ObjectMemberOf).MemberOf |Get-ADGroup|ForEach-Object {$_.Name} }

Basically what I am trying to achieve is get list of users from one group (1110 Users) and then get the recursive group membership for the users in that group. Then export it to an CSV where in one column you have the users and in the other column you have a list of groups(samaccountname).

Any help or if someone can point me in the right direction would be much appreciated. 

 

 

Add an additional window with question

$
0
0

Hello to all,

 

i am a beginner in powershell, maybe you can help me.

This script opens a window where you can enter a licensekey,

and this key will be written in a certain Reghive. ("HKLM:\SOFTWARE\CompanyName")

 

 

Now i try to add a question, after you added the licensekey.

A question should appear below the entered licensekey, if this key is correct, "Is this Key correct?"

if you press "no" it should go back to the first window where you can re-enter the key

if you press "yes" the key will be written and the program closes

 

 

if the RegKey is already present ("HKLM:\SOFTWARE\CompanyName")

there should be an additional question

"Should the licensekey be overwritten?"

press "yes" and the key will be overwritten and the program closes, if "no" the program closes because the key is already there.

 

 

i hope you can help me

greetings

 

 

Script:

 

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

 

$objForm = New-Object System.Windows.Forms.Form

$objForm.Text = "Data Entry Form"

$objForm.Size = New-Object System.Drawing.Size(300,200)

$objForm.StartPosition = "CenterScreen"

 

$objForm.KeyPreview = $True

$objForm.Add_KeyDown({if ($_.KeyCode -eq"Enter")

    {$x=$objTextBox.Text;$objForm.Close()}})

$objForm.Add_KeyDown({if ($_.KeyCode -eq"Escape")

    {$objForm.Close()}})

 

$OKButton = New-Object System.Windows.Forms.Button

$OKButton.Location = New-Object System.Drawing.Size(108,120)

$OKButton.Size = New-Object System.Drawing.Size(75,23)

$OKButton.Text = "OK"

$OKButton.Add_Click({$x=$objTextBox.Text;$objForm.Close()})

$objForm.Controls.Add($OKButton)

 

# $CancelButton = New-Object System.Windows.Forms.Button

# $CancelButton.Location = New-Object System.Drawing.Size(150,120)

# $CancelButton.Size = New-Object System.Drawing.Size(75,23)

# $CancelButton.Text = "Cancel"

# $CancelButton.Add_Click({$objForm.Close()})

# $objForm.Controls.Add($CancelButton)

 

$objLabel = New-Object System.Windows.Forms.Label

$objLabel.Location = New-Object System.Drawing.Size(10,20)

$objLabel.Size = New-Object System.Drawing.Size(280,20)

$objLabel.Text = "Please enter the licence key in the space below:"

$objForm.Controls.Add($objLabel)

 

$objTextBox = New-Object System.Windows.Forms.TextBox

$objTextBox.Location = New-Object System.Drawing.Size(10,40)

$objTextBox.Size = New-Object System.Drawing.Size(260,20)

$objForm.Controls.Add($objTextBox)

 

$objForm.Topmost = $True

 

$objForm.Add_Shown({$objForm.Activate()})

[void] $objForm.ShowDialog()

 

$x

 

New-Item -Path"HKLM:\SOFTWARE\CompanyName"

$RegistryPath=”HKLM:SOFTWARE\CompanyName\"

$Name=”Licensekey”

$Value=”$x”

 

NEW-ITEMPROPERTY $RegistryPath -Name $Name -Value $Value

 

 

 

 

Installation of Software's using SCCM from Service-Now

$
0
0

Trying to atomize the Installation of Software's using SCCM from Service-Now. written Powershell Scripts which run in the Firewall and connects to the SCCM Server. But we are getting the following error.

 

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)At C:\Users\zSvcServiceNowDev\AppData\Local\Temp\script.7552768326357979154.PS1:11 char:15+ $dev = gwmi -cn mtlwicmcs011 -ns root/sms/site_cas -query "select *from ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand0x00010001; Device not foundStack Trace:

 

On searching various sites, I understand that it might be one of the following issue:

1.     RPC Service is not running

2.     Firewall protecting the SCCM Server

3.     The server from where we are running the PowerShell and the SCCM server might be on different AD.

 

I would require your assistance in understanding why such errors occur and if there are any other reasons for this error/exception.  Any expert advice on PowerShell scripting is also appreciated.


Process in a disconnected session ends after 2 hours.

$
0
0

Hey guys.

Im having some issues with users that needs to run a process for longer then 2 hours i a

disconnected session.


This is the command that we use.

 invoke-Command -ComputerName Post-1 -InDisconnectedSession -ScriptBlock {Start-Process E:\P1349\FatigueWizard\Phase02\P1349-230-01-03-01-276\P1349-230-01-03-01-276-j2-cuto_1_56.bat}

 

 

It works as we want, its just that the remote process ends after 2 hours, even if its not done.  If im logged in on the remote machine, i can see in processes that the user starts the processes, but after 2 hours the processes ends and the user disappears.

 

Any help with this would be greatly appriciated.

/Pete

ADgroupMember script

$
0
0

Hi Guys,

I am learning powershell , This is basic script to display username, Displayname and title

 

$group=Get-Content'D:\New folder\list.txt'

 

 

Get-ADGroupMember

 

 

-Identity$group|

Where-Object

 

 

{ $_.objectClass -eq'user' } |

Get-ADUser

 

 

-Properties*|Select @{Name="NTID";Expression= {$_.MailNickName}},Displayname,Title

Actually i want include Group variable as well in output , Can you help how can i do it ?

 

import-csv with twist

$
0
0

Hi there

I have csv that looks like this:

upn,email

victort@test.corp,victor.test@test.com

$importedusers = Import-CSV c:\scripts\users.csv
foreach ($user in $importedusers)

If I wanted to add some prefix that I need for another command in the script later(lets say sip address)

how would I do it?

I tried something like this but doesn't seem to work(fails on the sip construction part):

Enable-CsUser –Identity $user.UPN -SipAddress  "sip:" +$user.email -RegistrarPool testing.test.corp -Verbose

Trusted Sites in Internet Option

$
0
0

I am using the following, in a batch file, to add a trusted site to the internet options security tab trusted sites area:

powershell -Command "& {set-location 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings';set-location ZoneMap\Domains;new-item 172.20.1.14;set-location 172.20.1.14;new-itemproperty . -Name http -Value 2 -Type DWORD;set-location 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings';set-location ZoneMap\ESCDomains;new-item 172.20.1.14;set-location 172.20.1.14;new-itemproperty . -Name http -Value 2 -Type DWORD;}"

It works as I wanted it to...... It populates the trusted sites window and shows up in the registry correctly..... However, it doesn't really make the site trusted..... If I add by hand, the site is trusted. Am I creating and populating the right keys in the right locations? By hand I do not need https, only http. I must be missing something ???

Many thanks!

Greg

 

hash tables square brackets and convertto-json

$
0
0

Hi usually I find I can work things like this out, but this one has had me turning circles for days :(

I am sure the answer is pretty easy and something I have missed , but I have tried all types of character escaping and I am at my wits end.

I am trying to do a post to a JSON web service. I create a hashtable and populate with some values.

The JSON request requires a "params" field with a nested hashtable within in it ("filter") as well as a filed called method (just a string) that's passed in

So I use the code below and I can post the data no problem

$post= @{"jsonrpc"="2.0";

 

 

"method"=$method

 

 

 

 

"params"= @{"filter"= @{}}

}

$post = $post | convertto-json

The issue is the above code works fine when the filter is blank ({}). The problem arises as the web service expects a JSON array with key-pairs within the filter (hence the reason for the nested hastable)

 

e.g.

"params"= @{"filter"= @{"eventid" = ["1"]}}

The problem is powershell doesn't like square brackets within the nested hashtable (filter) as its expecting a type declaration. So I try all different methods of escaping the characters and quoting. But I cannot get both powershell to accept the hashtable value with square brackets included or when I do manage to do this it screws up the JSON formatted data with "/"slashes or character codes.

The JSON should look like this:

{
"jsonrpc": "2.0",
"method": "mymethod",
"params": {
"eventtId": [
"1"
]

}

 Any help would be much appreciated I am sure it's just a formatting issue but for the life of me I cannot get it work :)

 

 

Use PowerShell to List RDS Sessions

$
0
0

Q: How can I use PowerShell to check all my Remote Desktop Services sessions?

A: If you want to use PowerShell instead of qwinsta.exe to list your Remote Desktop Services (RDS) sessions, you can do so as follows:

Read More

Prompt for a password with a mask using Powershell

$
0
0

Here’s some code that I absolutely know I’m going to need again in the future, what better place to put it than on my blog!

If you need to prompt the user for a password when using Powershell then you want to make sure that the value types in isn’t visible on the screen. That’s quite easy using the –AsSecureString parameter of the Read-Host cmdlet however its not quite so easy to retrieve the supplied value. The following code shows how to do it:

Read More


Test-Path from a list

$
0
0

This should be fairly easy and i did similar with test connection. I have a list of home drives, that were established in AD.

90% have this set but the folders do not exist. 

I used 

$Test = get-content C:\Test\Test.txt

 

$test | test-path returns  true fals value but not the path tested. 

I attempted to create them but multiple attempts later i am getting impatient.

If (!(Test-path $Test)) {new-item -type directory -path $test # I have tried variations of $item $items foreach-object and so on.

I am unable to figure this out.

 

I would like to do the test-path and return a list of paths that fail then from that list create the new Folder. I would also like to know if and how i could do this in one step rather than two.

 

Thank you

 

Check for snapin

$
0
0

This should be an easy one for someone with more experience than me in this area.  I am creating a process that requires some snapins:

Add-PSSnapin SqlServerProviderSnapin100

Add-PSSnapin SqlServerCmdletSnapin100

I want to check and see if they are loaded, if not then load them.  What is the easiest way to do that?

Creating a string from a get- command

$
0
0

I'm running this to get the primary SMTP address, I'm looping through a CSV that has a list of all the SamAccountNames that I'm modifying.

$Primary=get-mailbox -Identity $_.SamAccountName | Select-Object -ExpandProperty EmailAddresses | Where-Object {$_.SmtpAddress -ilike "*@york.uk*"} | select SmtpAddress

I want billy@york.uk (which is what I get if I just run the command without the $primary= bit). What I get is a string that looks like this @{SmtpAddress=billy@york.uk}. Which, if that is the string, I think won't work when I try to call that string in the command I have put in below

I've got to swap round the Set as Reply address for 200 users using a command like this

[PS] C:\>Set-Mailbox Paul.Cunningham -EmailAddresses SMTP:paulc@exchange2013demo.com,smtp:paul.cunningham@exchange2013demo.com

In the loop I want to use two stings $primary and $secondary

Set-Mailbox -Identity $_.SamAccountName -EmailAddresses SMTP:$Primary,smtp:$Secondary

So how do I stop the @{smtpAddress=} wrapping around the bit of data I want

Thanks

Jonathan

 


    

Need Help Passing Parameters

$
0
0

I have a script that accepts parameters, dynamically create and execute SQL commands to backup and restore Databases using a backup agent.  My desire is to use this script file in conjunction withe the "Start-Job" cmdlet so I can perform the process on multiple DB's at the same time.

It accepts the following parameters:

param
([string] $BackupServer, #Server to be backed up
 [string] $RestoreServer,#Server where backup is to be restore
 [string] $BackupDrive,  #Drive where backup file will be created
 [string] $DBName        #DB to be backed up and restored
 )

When I run it at the prompt as such:

\DB_Backup_Restore.ps1 "KCTS270" "WMDWM200D" "I$" "DW_Mart"

It work fine.

When I run  it at the prompt like this:

start-job -ScriptBlock {H:\PSHell\DB_Backup_Restore.ps1 } -ArgumentList "KCTS270", "WMDWM200D","I$", "DW_Core"

It runs and show up in the get-job info, but does nothing:

PS H:\pshell> get-job

Id              Name            State      HasMoreData     Location             Command                 
--              ----            -----      -----------     --------             -------                 
39              Job39           Running    True            localhost            H:\PSHell\DB_Backup_Re...
41              Job41           Running    True            localhost            H:\PSHell\DB_Backup_Re...

I have also tried it as:

start-job -ScriptBlock {H:\PSHell\DB_Backup_Restore.ps1 $BackupServer $RestoreServer $BackupDrive $DBName} -ArgumentList "KCTS270","WMDWM200D","I$","DW_Core"

start-job -filepath H:\PSHell\DB_Backup_Restore.ps1 -ArgumentList "KCTS270","WMDWM200D","I$","DW_Core"

start-job -ScriptBlock {H:\PSHell\DB_Backup_Restore.ps1 $args[0] $args[1] $args[2] $args[3]} -ArgumentList "KCTS270","WMDWM200D","I$","DW_Core"

All with similar results, I am fairly sure it has to do with the parameters not getting through, any thoughts?

PoSH, and WSDL\XML

$
0
0

Hi, been trying to figure out an actual question from a client, while learning at the same time, but am currently stuck.  The basic premise is that they have XML source from which they need to retrieve CustomerIDs and CustomerOrders which PoSH should dump in an array for further usage as other variables.

I found what looked to be a good article that was right up the alley of this issue, but so far haven't been able to get what I'm after by attempting to structure the script so ysimilar to:   http://blogs.technet.com/b/heyscriptingguy/archive/2009/11/18/hey-scripting-guy-november-18-2009.aspx

The u/p stuff is is bogus below of course, but the rest is workable.  The issue is that while "$i" is returning what it's supposed to, $i2 is just returning what looks to be "about" info.  I pasted what it's responding with below as well so you can see what I mean.

 

$username="username"
$securepassword=ConvertTo-SecureString"password"-AsPlainText-Force
$CustomerScriptID='992'
$password="password"
$cred=New-ObjectSystem.Management.Automation.PSCredential ($username,$securepassword)
$OnlineAPI=New-WebServiceProxy-Uri"https://api.securefreedom.com/vineit/webservice/onlineapi.asmx?WSDL"-Credential$cred
$ExtranetAPI=New-WebServiceProxy-Uri"https://api.securefreedom.com/vineit/webservice/extranetapi.asmx?WSDL"-Credential$cred
$t=$OnlineAPI.getType().namespace
$t2=$ExtranetAPI.getType().namespace
$attributes=New-Object ($t+".Credentials")
$attributes.Username="$username"
$attributes.Password="$password"
$attributes.Token=""
$attributes2=New-Object ($t2+".Credentials")
$attributes2.Username="$username"
$attributes2.Password="$password"
$attributes2.Token=""
$CustIDs=$OnlineAPI.GetRepCustomers($attributes,992) | select-object CustomerNumber | foreach { $_.CustomerNumber }
foreach ($CustIDin$CustIDs) {
$i=$OnlineAPI.GetCustomerInfo($attributes,$CustID)
$i
$i2=$ExtranetAPI.GetCustomerOrders($attributes2,$CustID)
$i2
}
Below is the output.  The first ($i) block is correct.  The 2nd ($i2) one is where the issue is . . . .
CustomerID : 2000
FirstName : Joe
LastName : Schmo
Company :
Email : joe@schmo.com
BillStreet1 : 123 Anywhere St
BillStreet2 : Suite 200
BillCity : NYC
BillState : NY
BillPostalCode : 10101
BillCounty : KINGS
BillCountry : USA
Phone1 : 2125551212
Phone2 : 2125551212
JoinDate : 2/9/2014 11:58:05 PM
SponserRepID : 992
SponsorBCNumber : 1
CustomerType : Regular
CustStatus : Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1webservice_onlineapi_asmx_WSDL.CustomerStatus
RequestID : 0
Success : 1
Message :

RemotingFormat : Xml
SchemaSerializationMode : IncludeSchema
CaseSensitive : False
DefaultViewManager : {System.Data.DataViewManagerListItemTypeDescriptor}
EnforceConstraints : True
DataSetName : NewDataSet
Namespace :
Prefix :
ExtendedProperties : {}
HasErrors : False
IsInitialized : True
Locale : en-US
Site :
Relations : {}
Tables : {}
Container :
DesignMode : False
ContainsListCollection : True
Any pointers, ideas, input is greatly appreciated!
Viewing all 6937 articles
Browse latest View live