Creating look up column using powershell.

I have a Sharepoint list "Studentparent" in my website. I am trying to create a custom list "studentchild" list using powershell code and this studentchild list will be having a look up column getting ID column from "StudentParent"
list - So the code is 
#To which site u want to create the list 
$spWeb=Get-SPWeb -Identity http://XYZ
#List type or template 
$spTemplate = $spWeb.ListTemplates["Custom List"]
#Get all the lists to the listcollection
$spListCollection=$spWeb.Lists
#adding the new list to the list collection
$spListCollection.Add("StudentChild","StudentChild",$spTemplate)
#get the path of subsite and sitecollecion 
$path = $spWeb.url.trim()
#get the list to the list object
$spList = $spWeb.GetList("$path/Lists/StudentChild")
$ParentList = $spWeb.Lists.item("StudentParent")
$spList = $WebObj.Lists["StudentChild"]
$spList.Fields.AddLookup("ChildLookupField",$ParentList.id,$false)
$spChildListLookupField = $spList.Fields["ChildLookupField"]
$spChildListLookupField.LookupField = $ParentList.Fields["ID"]
$spChildListLookupField.RelationshipDeleteBehavior = [Microsoft.SharePoint.SPRelationshipDeleteBehavior]::Restrict
$spChildListLookupField.Update()
$Views = $spList.Views["All Items"]
$Views.ViewFields.Add("ChildLookupField")
$Views.Update()
but when i run this code - I am getting error
Cannot index into a null array.
+ $spList = $WebObj.Lists["StudentChild"]

Hi Mahesh,
The object "$WebObj" is not instantiated in your code. You have already assigned the value to $splist in following line.
$spList = $spWeb.GetList("$path/Lists/StudentChild")
and once again you are assigning value
$spList = $WebObj.Lists["StudentChild"] // redundant and it should be $spWeb.Lists["StudentChild"]
Please let us know if this fixes your issue.
Thanks,
M. Gubendra Raj

Similar Messages

  • Check the type of column using powershell within a splist

    hi,
    i have a column called BU in my splist in many site collections.i had created using with lookup datatype and  now  since my design is changed i  want to create this as  a a choice field with few default values. Can anyone please
    help how to check this using powershell? i mean check the  datatype of  column using PS and  if its lookup then need to delete the list and recreate it with choice field. i know hot to create a splist with choice field using PS,
    but  i am unable to get the code for existence of lookup or choice field.
    $web = Get-SPWeb "http://sitename"
    $fieldnamebu= "BU"
    $mysplist = $web.lists["mysplist1"]
    $lookupfieldA="Lookup"
    foreach($sfield in $mysplist.fields)
    # how to check the datatype pf column as lookup
    if ( ##todo#### -eq $lookupfieldA )
    $mysplist.Delete();
    $web.upate();
    create the splist with choice field$spTemplate = $web.ListTemplates["Custom List"] #Create SPTemplate instance of Type Custom List
    $web.Lists.Add("mysplist1", "for approvers", $spTemplate)   #Add list to site$spList = $spWeb.Lists["mysplist1"]    #Get list instance
    $spList.OnQuickLaunch = $True   $spList.Update()    #Update list to reflect changes in site
    $spFieldType = [Microsoft.SharePoint.SPFieldType]::Text      #Get Field type to create
    $spList.Fields.Add("Mymn", $spFieldType, $false)      #Add new field to list}

    HI,
    To get the field types please refer below link...
    foreach ($field in $list.Fields) #Get all fields in lists
    if($spField -eq $field.Title) #if field in lists equals field in views
    Write-Host $spField " | " $field.Type -ForegroundColor Green #Write out each field (column)
    https://gallery.technet.microsoft.com/office/SharePoint-Get-SPFields-49039dc0
    To Create Choice field follow below reference:
    https://social.msdn.microsoft.com/Forums/en-US/8a874677-91cf-41dd-a601-f0dd7fdce213/creating-a-choice-column-via-powershell
    http://adicodes.com/add-fields-to-list-with-powershell-in-sharepoint-2010/
    Don't
    forget to mark it as an Answer if it resolves your issue and Vote Me as helpful if it useful.
    Mahesh

  • Creating a Scheduled Task using PowerShell v4

    So here is my question.  I'm trying/wanting to create a scheduled task using PowerShell v4 on Server 2012R2.  I want to task to run on the 1st day of every month.  The parameter for -Monthly -Day is not available.  I need to use PowerShell
    to create the Scheduled Task because the Task will be running with a group Managed Service Account credentials so the Scheduled Task can not be created via the Task Scheduler GUI.
    Thanks in Advance

    Here is a functioning task It can be easily edited in PowerShell or in notepad to alter the timing
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <RegistrationInfo>
    <Author>W8TEST\user01</Author>
    </RegistrationInfo>
    <Triggers>
    <CalendarTrigger>
    <StartBoundary>2014-06-04T21:31:32.0459499</StartBoundary>
    <Enabled>true</Enabled>
    <ScheduleByMonth>
    <DaysOfMonth>
    <Day>1</Day>
    <Day>12</Day>
    <Day>24</Day>
    </DaysOfMonth>
    <Months>
    <January />
    <February />
    <March />
    <April />
    <May />
    <June />
    <July />
    <August /
    <September />
    <October />
    <November />
    <December />
    </Months>
    </ScheduleByMonth>
    </CalendarTrigger>
    </Triggers>
    <Principals>
    <Principal id="Author">
    <RunLevel>LeastPrivilege</RunLevel>
    <UserId>W8TEST\jvierra</UserId>
    <LogonType>InteractiveToken</LogonType>
    </Principal>
    </Principals>
    <Settings>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <IdleSettings>
    <StopOnIdleEnd>true</StopOnIdleEnd>
    <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
    </Settings>
    <Actions Context="Author">
    <Exec>
    <Command>notepad.exe</Command>
    <Arguments>test.txt</Arguments>
    <WorkingDirectory>c:\temp</WorkingDirectory>
    </Exec>
    </Actions>
    </Task>
    I have edited and reloaded the XML many, many times.  It works very nicely.
    ¯\_(ツ)_/¯

  • Creating user in AD using powershell

    Hi,
    How to create ad user in opalis using powershell?

    Hi,
    best will be, you take the "Run .Net Activity" and put your PowerShell Script in there.
    Example Script
    new-aduser $LoginName -GivenName $FirstNameField -Surname $LastnameField -DisplayName $Displayname -UserPrincipalName "$[email protected]" -ChangePasswordAtLogon $true -AccountPassword (ConvertTo-SecureString –AsPlainText “password1password_1” -Force) -Path "OU=$OU,OU=User,OU=Company,DC=domain,DC=com" -Company $Company -Department $Department -enabled $true -EmployeeNumber $EmployeeNumber -Description $EmployeeNumber -EmailAddress $SMTPAdresse -Division $Division
    Seidl Michael | http://www.techguy.at |
    twitter.com/techguyat | facebook.com/techguyat

  • Creating Windows Basic Task using powershell

    Hello Everyone,
    Please help me out in the below situation:
    I have to create a basic windows task using powershell to run a script on a specific date and time.
    Let me make it even clear :
    I have a csv say,
    D:\xyz.csv
    ServerName ,  Date  , Time
    Random1,   11/15/2014,01:00:00PM
    Random2,   12/01/2015,03:00:00PM
    ...and so on
    I also have a script at E:\TestingServer.ps1
    I need to create list of windows tasks to invoke TestingServer.ps1 with parameters as servername and Time of task as given date and time in csv.
    Task1- with input as ServerName at Date and time from CSV
    Task2-with input as ServerName at Date and time from CSV

    Well here is a good article showing howto do this:
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/18/create-a-powershell-scheduled-job.aspx
    ¯\_(ツ)_/¯

  • How to create a context menu using powershell

    Hi 
    i would like to create a context menu for powershell but i am getting an error after powershell menu is created
    "This file does not have a program associated to it. i am using this script . I am trying to create a powershell shortcut on folders."
    also once it gets created i would like to open powershell as admin always
    New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
    Test-Path HKCR:\Directory\shell\Powershell
    New-Item -Path HKCR:\Directory\shell -Name Powershell
    Set-Item -Path HKCR:\Directory\shell\Powershell -Value "Open Powershell Here" 
    New-Item -Path HKCR:\Directory\shell\Powershell\key -Value "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command ""Set-Location -LiteralPath '%L'"""

    You need to put forth the effort to ask a good, clear, and meaningful question.
    As it stands, you seem to have a record of asking nearly unintelligible questions that take a great amount of effort for others to guess what you are asking. This is bad because it wastes everyone's time.
    Read these for some good information on how to ask good questions:
    Posting guidelines
    Handy tips for posting to this forum
    How to ask questions in a technical forum
    Rubber duck problem solving
    How to write a bad forum post
    -- Bill Stewart [Bill_Stewart]

  • Create Offline Address Book using powershell - PublicFolderDistributionEnabled not found

    We are using the following commands to create a new Offline Address book using powershell. The command New-OfflineAddressBook runs successfully and creates an Offline Address Book. However when we try to set the value of PublicFolderDistributionEnabled property
    using Set-OfflineAddressBook we get the following exception
    Remote Exception: A parameter cannot be found that matches parameter name 'PublicFolderDistributionEnabled'
                try
                    using (Runspace runSpace = OpenRunspace())
                        // Create offline address book command
                        var command = new Command("New-OfflineAddressBook");
                        command.Parameters.Add("Name", name);
                        command.Parameters.Add("AddressLists", addressListName);
                        command.Parameters.Add("VirtualDirectories", OABServer);
                        // Execute command
                        if ((res = ExecuteShellCommand(runSpace, command)) == false)
                            return false;
                        // Set offline address book command
                        var command1 = new Command("Set-OfflineAddressBook");
                        command1.Parameters.Add("Identity", name);
                        command1.Parameters.Add("PublicFolderDistributionEnabled", publicFolderEnabled);
                        command1.Parameters.Add("Confirm", new SwitchParameter(false));
                        // Execute command
                        if ((res = ExecuteShellCommand(runSpace, command1)) == false)
                            DeleteOfflineAddressBook(name);
                            return false;
                catch (Exception ex)
                    DeleteOfflineAddressBook(name);
                    throw;

    If your Exchange version is 2013 it supports only the web distribution method.
    Please follow this to create OAB in Exchange2013 
    http://blogs.technet.com/b/exchange/archive/2013/01/14/managing-oab-in-exchange-server-2013.aspx
    Please check this for the details of OAB in Exchange2013
    http://blogs.technet.com/b/exchange/archive/2012/10/26/oab-in-exchange-server-2013.aspx
    If it Exchange2010 please check
    this
    Thanks, MAS
    Please mark as helpful if you find my comment helpful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.

  • Update workflow status column using PowerShell

    Hi All,
    Using PowerShell i want to update the 'Document Status' column as 'Approved'  if it is 'Pending' when it is approved and Task Status is = 'Completed'
    Intermittently my custom workflow is not updating the 'Document Status' column as 'Approved' though it is approved and Task Status is = 'Completed'
    So I thought about running a PowerShell script to work around it.
    Can you please help me for the script.
    Thanks & Regards
    MD.Liakath ali

    Hi,
    The following PowerShell script for your reference:
    $SPWeb = Get-SPWeb http://site
    $List = $SPWeb.Lists["ListName"]
    $items = $List.Items
    foreach ($item in $items) {
    $taskStatus = $item["Task Status"]
    $docStatus = $item["Document Status"]
    if ($taskStatus -eq "Completed" -and $docStatus -eq "Pending")
    $item["Document Status"] = "Approved"
    $item.Update()
    $list.Update()
    $SPWeb.Dispose()
    If the 'Document Status' column is "Approval Status" column and your workflow is an approval workflow, the following articles may be helpful:
    Approval workflow does not update the approval status of items
    https://kanithi.wordpress.com/2014/03/13/approval-workflow-does-not-update-the-approval-status-of-items/
    SharePoint 2010 Approval Workflow with Content Approval
    https://eointherealworld.wordpress.com/2010/12/29/sharepoint-2010-approval-workflow-with-content-approval/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Setting default value of document library column using powershell

    Created document library based on template which is using custom content type containing managed metadata based column.
    I can upload documents. Everything looks normal except when I visit Column default value settings page in DL settings, I get error message below
    Application error when access /_layouts/15/ColumnDefaults.aspx, Error=Value does not fall within the expected range.   at Microsoft.SharePoint.SPWeb.GetWebRelativeUrlFromUrl(String strUrl, Boolean includeQueryString, Boolean canonicalizeUrl)    
    at Microsoft.Office.Server.WebControls.MetaDataNavTree.TreeViewDataBound(Object sender, EventArgs e)     at System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect()     at Microsoft.Office.DocumentManagement.MetadataNavigation.MetadataNavigationContext.OnTreeViewLoad(SPTreeView
    spTreeView)     at Microsoft.Office.Server.WebControls.MetaDataNavTree.PerLocationPageLoad()     at Microsoft.Office.DocumentManagement.Pages.ColumnDefaultsPage.OnLoad(EventArgs e)     at System.Web.UI.Control.LoadRecursive()
        at System.Web.UI.Page.ProcessRe...  6bf73b9c-e4f3-10ae-0f74-9672cdd9936f
    I tried many things but nothing seems to work. When I create document library using SharePoint OOB template, everything works.
    Any help would be appreciated.
    Thanks.

    I found another way to fix this. Thanks to you pointing me to the file "{List Name}/Forms/client_LocationBasedDefaults.html"
    I found the difference between this file and the one of a list that worked:
    I had "&" in the names of some folders. The recreated subsites from a template that contained such folders in the document library had the problem descriped by the OP. In the recreated client_LocationBasedDefaults.html there were actual '&'
    in the folder names instead of '%26' escape characters. After replacing those characters with their escaped version everything worked as expected again.

  • Error creating groups in SCSM using PowerShell

    Hello Everyone,
    I am trying to create a bunch of groups and queues within SCSM to seperate work items and CIs from different customers. For example, I have started off by entering the console and creating a group called "Company 1" in my groups (found in Library).
    "Company 1" group defines dynamic members of this group by specifying the following query: The "Active Directory" class, if the Users Company field contains value "Company 1" then add to the group.
    I also need to create a Queue containing all work items for "Company 1".
    I can generate a list of all the company's to enter in a csv, and know enough powershell to import it and read the file line by line
    However, I am having trouble creating the objects. My method was:
    #Get the name of the class I want to create an object of and store it in a variable
    $groupClass = Get-SCSMClass -Name "Microsoft.SystemCenter.ConfigItemGroup$"
    #Return the variable stored to ensure this part is working (Debug purposes)
    $groupClass
    #Get the active status of an object and store it in a variable
    $objStatus = Get-SCSMEnumeration -Name System.ConfigItem.ObjectStatusEnum.Active
    #Return the variable stored to ensure this part is working (Debug purposes)
    $objStatus
    #Create the object stored in my class variable and modify the DisplayName and ObjectStatus properties.
    New-SCSMObject -Class $groupClass -PropertyHashtable (@{DisplayName = "Test"; ObjectStatus = $objStatus;}) -Debug -Verbose
    Once I got this code working my idea was to read from csv and loop the creation process. However, I keep getting the error: "Cannot create objects of an abstract class"
    Am I using the incorrect class to create a group? If so, what is the correct class to select? Is there a more efficient method to do this? Any ideas at all please share, thank you in advance :)

    @Aaron
    Sorry for the late response, I went on vacation and just returned. So basically, I ended up making all these groups manually since I could not find a way to automate the discovery rule creation through script.
    I am now trying to create queues for each of these clients, one queue for each type of work item. I'm working with a client list of around 100, so that means creating almost 300 queues. This would be crazy to do manually - So I began working on a script
    to do this.
    This is what I have come up with:
    # Script Written by SirLearnAlot
    # January 2015
    # Revision 2
    # Get required queues categories (classes)
    $incident = Get-SCSMClass -Name "System.WorkItem.Incident$"
    $RMA = Get-SCSMClass -Name "COMPANY.RMA.Class$"
    $MACD = Get-SCSMClass -Name "System.WorkItem.ServiceRequest$"
    # ManagementPack to store queues in (MP Must be created through PS or else will throw error)
    $MP = Get-SCManagementPack -Name "COMPANY.Queues"
    # Import list of customers (names for the queues)
    $content = Get-Content 'C:\Users\portalservice\Desktop\list.txt'
    foreach ($customer in $content){
    New-SCQueue -Verbose -Name "Incident - $customer" -class $incident -ManagementPack $MP -Filter "Customer_List -eq '$customer'";
    New-SCQueue -Verbose -Name "RMA - $customer" -class $RMA -ManagementPack $MP -Filter "Customer_List -eq '$customer'";
    New-SCQueue -Verbose -Name "MACD - $customer" -class $MACD -ManagementPack $MP -Filter "Customer -eq '$customer'"}
    However I kept running into errors.
    I realized I needed to point the Customer_List found in the incident class to the other two classes, so I had to re-author them to add the customer field and point towards the incident MP to retrieve the enum. I did this successfully with Service Requests,
    but am having trouble applying the same concept to my "RMA" class.
    I have tested the code with both Incidents and Service Requests now and can successfully create the queues correctly, but need to fix my RMA class to complete the task.
    I now cannot seal my MP because I keep running into errors (I am sure I made a typo somewhere or am missing some line or something)
    Any help would be appreciated I am getting extremely frustrated!

  • Creating Subdomain DNS Entries using Powershell

    Hello There,
    I created a Powershell script to add some SRV records on a AD-Integrated Zone that Works fine.
    The problem is, I created some subdomains (Right-Clicking on the DNS zone and then adding a new Domain) and I cannot create the records on these subdomains using the shell.
    My Script is this one:
    Import-CSV TEST.CSV | ForEach-Object -Process {Add-DnsServerResourceRecord -ZoneName ccr.intranet -A -DomainName $_.Hostname -Ipv4Address $_.IP}
    It´s working really fine. But, when I try to reference the zone as subdomain.ccr.intranet (example), I cannot create the record, because it tells me that the subdomain is not actually a zone.
    Is there any ways to create these records using the Powershell Script? I have more than 300 srv records and, even I need to create then manually, I really doubt that this is the Only way to do that.
    Thanks!

    ... I'm a little confused, sorry.  So, you want to create an SRV record in ipaosb.ccr.intranet such as _sip._tcp.ipaosb.ccr.intranet, but when you specify the zone as ipaosb.ccr.intranet, it tells you no such zone.
    What happens if you try this?
    Add-DnsServerResourceRecord -Srv -ZoneName ccr.intranet -Name _sip._tcp.ipaosb -DomainName as2metrobah.ccr.intranet -Port 5060 -Priority 0 -Weight 0
    Where _sip._tcp.ipaosb would be replaced by $_.hostname, and reflected in the CSV?
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer".
    SWC Unified Communications

  • Best way to Create Shared Folder using Powershell

    Hi
    Does anyone have any recommendations on creating a shared folder using PowerShell? I've used new-item to create a folder, is there a way to share it and give specific name?
    Cheers

    Hi Shane,
    I’m writing to just check in to see if the suggestions
    were helpful. If you need further help, please feel free to reply this post directly so we will be notified to follow it up.
    If you have any feedback on our support, please click here.
    Best Regards
    Anna
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Set default quota for farm using powershell

    Hello, 
    Looking for a powershell solution to creating a default quota template. So when new sites are created they default to that quota, or can be changed if needed. 
    Thanks, 
    Will 

    This article is for 2010, but it should work the same in 2013.  This PowerShell just creates the quota template.  You will need to pick the quota template when creating a site collection.  There is no way to set a default quota template for
    regular site collections.
    http://www.sharepointdiary.com/2013/08/create-sharepoint-quota-templates-using-powershell.html
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • Filtering a Look up column on page load.

    I'm trying to filter a look up column using something like CAML to only show me a subset of the values in a list. Basically when the New or Edit Form loads I'd like to parse a value out of the URL (in my case the Document Set Name) and then filter a the
    look up. 
    To understand what I'm trying to do: The business requirement is to create a look up column to the same library we're working in that only shows documents within the current Document Set (very similar to a folder if your not familiar) as Options. 
    If anyone can think of an easier way to accomplish this or something similar please let me know. Otherwise if anyone has experience dynamically filtering look up columns, I'm curious to hear how you accomplished it. 
    Thanks.

    try these links:
    http://howididit-sharepoint.blogspot.in/2012/04/filtering-lookup-columns.html
    http://sharepoint-works.blogspot.in/2012/02/cascading-dropdown-or-filtered-values.html
    http://www.codeproject.com/Articles/203818/SharePoint-Filtering-Lookup-column-using-Java
    you can use cascading dropdown using spservice
    jquery.

  • How to add hash table values to SQL Table using Powershell

    Hi,
    I have sharepoint list with four(column1, column2, column3,column4)columns.I am reading the list column values and adding to hashtable. Now I want to add values from hastable to SQL table with four(column1, column2, colum3,column4)columns using powershell.
    I have written the following script for single column but I would like to know how to add values for multiple columns.
                if(($key -eq "Column1") )
                   $SqlQuery = "INSERT INTO [TableName] ([Column1]) VALUES ('" + $HashTable.Item($key) +"')"
                   #Set new object to connect to sql database
                   $connection = new-object system.data.sqlclient.sqlconnection
                   $Connection.ConnectionString ="server=SQLServerName;database=SQLDBName;Integrated Security = True;"
              $connection #List connection information 
                   $connection.open() #Open Connection
                 $Cmd = New-Object System.Data.SqlClient.SqlCommand
                 $Cmd.CommandText = $SqlQuery
                   $Cmd.Connection = $connection
                  $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
                  $SqlAdapter.SelectCommand = $SqlCmd
                  $DataSet = New-Object System.Data.DataSet
                  $SqlAdapter.Fill($DataSet)
                  $DataSet.Tables[0]
                  $connection.Close()
    Can anybody please help me out to accomplish the task? Any help would be greatly appreciated.
    AA.

    Hi AOk2013,
    Not knowledgable on PowercShell, based on my understanding on HashTable in Java, Some modification you can make in your code to achieve your requirement.
    If the Keys in HashTable are "Column1","Column2","Column3","Column4", you can reference below.
    if(($key -eq "Column1") ) #what is the purposed of this if ?
    #$SqlQuery = "INSERT INTO [TableName] ([Term]) VALUES ('" + $HashTable.Item($key) +"')"
    #specify the real column names in the table
    $SqlQuery = "INSERT INTO [TableName] ([ColumnA],[ColumnB],[ColumnC],[ColumnD]) VALUES ('" + $HashTable.Item("Column1") +"','"+ $HashTable.Item("Column2") +"','"+$HashTable.Item("Column3") +"','"+$HashTable.Item("Column4") +"')"
    #Set new object to connect to sql database
    $connection = new-object system.data.sqlclient.sqlconnection
    $Connection.ConnectionString ="server=SQLServerName;database=SQLDBName;Integrated Security = True;"
    $connection #List connection information
    $connection.open() #Open Connection
    $Cmd = New-Object System.Data.SqlClient.SqlCommand
    $Cmd.CommandText = $SqlQuery
    $Cmd.Connection = $connection
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet)
    $DataSet.Tables[0]
    $connection.Close()
    Since your question is regarding PowerShell, I would suggest you post it in a dedicated
    PowerShell Forum. It is more appropriate and more experts will assist you.
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for

  • One year on MacBook Pro (almost) - disappointed

    For Christmas last year, I was offered a 15 inch MacBook Pro. It was, by far, the best present I ever got. Up until then, I was schlepping around a Dell Latitude. I had had it for six years and that Dell was a reliable little machine, even though it

  • Problem with multiple iPods on one computer

    I just got a new Ipod and since my computer's internet is down I'm using the computer my mother and brother use for their iPods. We each have our own user profile on the computer. However when I plugged my iPod into the computer for the first time it

  • HT1414 The itunes is updated! Where is the Summary tab?

    I want to restore my iPhone, but I cannot find the Summary tab in iTunes.

  • Unable to delete Account ..

    Hi, I am a newbie to this phone (Palm Pre - (ISP) Bell Canada), and am having some issues deleting an account that was setup when the phone was 1st purchased. Ok, the phone is not mine, but our Senior VP's. He is a techie (but not a knowlegable 1 ..)

  • Getting system error message: APSDaeon.exe

    Trying to download latest Apple update to my Toshiba laptop.  I got a system error message: APSDaeon.exe. I uninstalled Itunes and tried again, but got the same message.