locked
Having issues with Invoke-Sqlcmd RRS feed

  • Question

  • So I am trying to use Invoke-Sqlcmd to populate a Sql Server 2014 db, but I keep getting an error when it tries to add the record. The issue could be my formatting of the cmdlet, so I wanted to know if the following will work:

    function Add-Record ($computerObj)
    {
    	try
    	{
    		Invoke-Sqlcmd -ServerInstance $datasource -database $database -variable ($ComputerName = $computerObj.ComputerName, $Model = $computerObj.Model,`
    		$Autologon = $computerObj.Autologon, $BCA = $computerObj.BCA, $NewWNum = $computerObj.NewWNum, $Description = $computerObj.Description,`
    		$Status = $computerObj.Status, $RefreshDate = $computerObj.RefreshDate, $InstallTech = $computerObj.InstallDate, $Building = $computerObj.Building,`
    		$Floor = $computerObj.Floor, $Dept = $computerObj.Dept, $OS = $computerObj.OS, $Monitor1 = $computerObj.Monitor1, $Monitor2 = $computerObj.Monitor2,`
    		$Printers = $computerObj.Printers, $Adapter = $computerObj.Adapter, $MacAddress = $computerObj.MACAddress, $DHCPEnabled = $computerObj.DHCPEnabled, `
    		$IP = $computerObj.IPAddress, $SubnetMask = $computerObj.SubnetMask, $Gateway = $computerObj.Gateway, $DNSPrimary = $computerObj.DNSPrimary,`
    		$DNSSecondary = $computerObj.DNSSecondary, $SCCMApps = $computerObj.SCCMApps, $ManualApps = $computerObj.ManualApps, $Notes = $computerObj.Notes,`
    		$TopConsoleUser = $computerObj.TopConsoleUser, $TCU_FirstName = $computerObj.TCU_FirstName, $TCU_LastName = $computerObj.TCU_LastName, $TCU_Site = $computerObj.TCU_Site,`
    		$TCU_Dept = $computerObj.TCU_Dept, $TCU_JobTitle = $computerObj.TCU_JobTitle, $MgrFirstName = $computerObj.MgrFirstName, $MgrLastName = $computerObj.MgrLastName) -InputFile "Y:\RefreshTest\InsertQuery.sql"
    	}
    	catch
    	{
    		Write-Debug $_.Exception.Message
    	}
    	
    }

    The $computerObj object contains all the values I need, but when I run the above function as part of a larger script, I get the following error: "Debug: The property 'MgrFirstName' cannot be found on this object. Verify that the property exists and can be set." I've verified several times that the Sql table is correct as far as the column names are concerned, as well as the max column size. If I comment out MgrFirstName in the function, it then goes to another property (MgrLastName I think). I'm just trying to pass in an object that is filled with data that needs to be written to the db. Any help would be appreciated.

    Brian

    Tuesday, May 16, 2017 5:11 PM

All replies

  • This is what you have.  It does not explain what you are trying to do.

    $sqlvars = (
    	$ComputerName = $computerObj.ComputerName,
    	$Model = $computerObj.Model,`
    	$Autologon = $computerObj.Autologon,
    	$BCA = $computerObj.BCA,
    	$NewWNum = $computerObj.NewWNum,
    	$Description = $computerObj.Description,
    	$Status = $computerObj.Status,
    	$RefreshDate = $computerObj.RefreshDate,
    	$InstallTech = $computerObj.InstallDate,
    	$Building = $computerObj.Building,`
    	$Floor = $computerObj.Floor,
    	$Dept = $computerObj.Dept,
    	$OS = $computerObj.OS,
    	$Monitor1 = $computerObj.Monitor1,
    	$Monitor2 = $computerObj.Monitor2,
    	$Printers = $computerObj.Printers,
    	$Adapter = $computerObj.Adapter,
    	$MacAddress = $computerObj.MACAddress,
    	$DHCPEnabled = $computerObj.DHCPEnabled,
    	$IP = $computerObj.IPAddress,
    	$SubnetMask = $computerObj.SubnetMask,
    	$Gateway = $computerObj.Gateway,
    	$DNSPrimary = $computerObj.DNSPrimary,
    	$DNSSecondary = $computerObj.DNSSecondary,
    	$SCCMApps = $computerObj.SCCMApps,
    	$ManualApps = $computerObj.ManualApps,
    	$Notes = $computerObj.Notes,
    	$TopConsoleUser = $computerObj.TopConsoleUser,
    	$TCU_FirstName = $computerObj.TCU_FirstName,
    	$TCU_LastName = $computerObj.TCU_LastName,
    	$TCU_Site = $computerObj.TCU_Site,
    	$TCU_Dept = $computerObj.TCU_Dept,
    	$TCU_JobTitle = $computerObj.TCU_JobTitle,
    	$MgrFirstName = $computerObj.MgrFirstName,
    	$MgrLastName = $computerObj.MgrLastName
    )
    Invoke-Sqlcmd -ServerInstance $datasource -database $database -variable $sqlvars -InputFile Y:\RefreshTest\InsertQuery.sql
     
    
    There is no need for line continuation if you use an array correctly.


    \_(ツ)_/

    Tuesday, May 16, 2017 8:27 PM
  • Here is an example:

    $MyArray = "MyVar1 = 'String1'", "MyVar2 = 'String2'" 
    Invoke-Sqlcmd -Query "SELECT `$(MyVar1) AS Var1, `$(MyVar2) AS Var2;" -Variable $MyArray 

    Here is how to create that string array:

    $sqlvars = (
    	"ComputerName = '$($computerObj.ComputerName)'",
    	"Model = '$($computerObj.Model)'",
    	"Autologon = '$($computerObj.Autologon)'",
       ... etc
    )

    You must convert all assignments to strings and create your SQL variables like this in the script file.

    Insert Into table(ComputerName, ...) Values($(ComputerName), ...)


    \_(ツ)_/


    • Proposed as answer by Hello_2018 Wednesday, May 17, 2017 6:58 AM
    • Edited by jrv Wednesday, May 17, 2017 3:25 PM
    Tuesday, May 16, 2017 8:35 PM
  • Here is an example:

    $MyArray = "MyVar1 = 'String1'", "MyVar2 = 'String2'" 
    Invoke-Sqlcmd -Query "SELECT `$(MyVar1) AS Var1, `$(MyVar2) AS Var2;" -Variable $MyArray 

    Here is how to create that string array:

    $sqlvars = (
    	"ComputerName = '$($computerObj.ComputerName)'",
    	"Model = '$($computerObj.Model)'",
    	"Autologon = '$($computerObj.Autologon)'",
       ... etc
    )

    You must convert all assignments to strings and create your SQL variables like this in the script file.

    Insert Into table(ComputerName, ...) Values(${ComputerName), ...)


    \_(ツ)_/


    I will try your solution, but I just want to make sure I understand this correctly. I've made the change in my script to change the syntax for creating an array of variables, but I want to ask about the Insert statement - the '{' looks out of place. Should it be a '(' instead?
    Wednesday, May 17, 2017 3:21 PM
  • Yes.  I fixed it in my example.

    The notation is common to parameter passing in the Event log, SQL and other utilities/


    \_(ツ)_/

    Wednesday, May 17, 2017 3:26 PM
  • OK, here is what I have in my Add-Record function:

    function Add-Record ($computerObj)
    {
    	
    	$sqlvars = (
    	"ComputerName = '$($ComputerName = $computerObj.ComputerName)'", "Model = $($Model = $computerObj.Model)'", "Autologon = '$($Autologon = $computerObj.Autologon)'",
    	"BCA = '$($BCA = $computerObj.BCA)'", "NewWNum = '$($NewWNum = $computerObj.NewWNum)'", "Description = '$($Description = $computerObj.Description)'",
    	"Status = '$($Status = $computerObj.Status)'", "RefreshDate = '$($RefreshDate = $computerObj.RefreshDate)'", "InstallTech = '$($InstallTech = $computerObj.InstallDate)'",
    	"Building = '$($Building = $computerObj.Building)'", "Floor = '$($Floor = $computerObj.Floor)'", "Dept = '$($Dept = $computerObj.Dept)'", "OS = '$($OS = $computerObj.OS)'",
    	"Monitor1 = '$($Monitor1 = $computerObj.Monitor1)'", "Monitor2 = '$($Monitor2 = $computerObj.Monitor2)'", "Printers = '$($Printers = $computerObj.Printers)'",
    	"Adapter = '$($Adapter = $computerObj.Adapter)'", "MACAddress = '$($MacAddress = $computerObj.MACAddress)'", "DHCPEnabled = '$($DHCPEnabled = $computerObj.DHCPEnabled)'",
    	"IPAddress = '$($IP = $computerObj.IPAddress)'", "SubnetMask = '$($SubnetMask = $computerObj.SubnetMask)'", "Gateway = '$($Gateway = $computerObj.Gateway)'",
    	"DNSPrimary = '$($DNSPrimary = $computerObj.DNSPrimary)'", "DNSSecondary = '$($DNSSecondary = $computerObj.DNSSecondary)'", "SCCMApps = '$($SCCMApps = $computerObj.SCCMApps)'",
    	"ManualApps = '$($ManualApps = $computerObj.ManualApps)'", "Notes = '$($Notes = $computerObj.Notes)'", "TopConsoleUser = '$($TopConsoleUser = $computerObj.TopConsoleUser)'",
    	"TCU_FirstName = '$($TCU_FirstName = $computerObj.TCU_FirstName)'", "TCU_LastName = '$($TCU_LastName = $computerObj.TCU_LastName)'", "TCU_Site = '$($TCU_Site = $computerObj.TCU_Site)'",
    	"TCU_Dept = '$($TCU_Dept = $computerObj.TCU_Dept)'", "TCU_JobTitle = '$($TCU_JobTitle = $computerObj.TCU_JobTitle)'", "MgrFirstName = '$($MgrFirstName = $computerObj.MgrFirstName)'",
    	"MgrLastName = '$($MgrLastName = $computerObj.MgrLastName)'")
    	try
    	{
    		Invoke-Sqlcmd -ServerInstance $datasource -database $database -variable $sqlvars -InputFile "Y:\RefreshTest\InsertQuery.sql"
    	}
    	catch
    	{
    		Write-Debug $_.Exception.Message
    	}
    	
    }

    And here is my InsertQuery.sql:

    INSERT INTO [dbo].[Refresh]
               ([ComputerName]
               ,[Model]
               ,[Autologon]
               ,[BCA]
               ,[NewWNum]
               ,[Description]
               ,[Status]
               ,[RefreshDate]
               ,[InstallTech]
               ,[Building]
               ,[Floor]
               ,[Dept]
               ,[OS]
               ,[Monitor1]
               ,[Monitor2]
               ,[Printers]
               ,[Adapter]
               ,[MACAddress]
               ,[DHCPEnabled]
               ,[IPAddress]
               ,[SubnetMask]
               ,[Gateway]
               ,[DNSPrimary]
               ,[DNSSecondary]
               ,[SCCMApps]
               ,[ManualApps]
               ,[Notes]
               ,[TopConsoleUser]
               ,[TCU_FirstName]
               ,[TCU_LastName]
               ,[TCU_Site]
               ,[TCU_Dept]
               ,[TCU_JobTitle]
               ,[MgrFirstName]
               ,[MgrLastName])
         VALUES($(ComputerName), 
    	     (Model),
                 (Autologon),
    	     (BCA),
                 (NewWNum),
                 (Description),
                 (Status),
                 (RefreshDate),
                 (InstallTech),
                 (Building),
                 (Floor),
                 (Dept),
                 (OS),
                 (Monitor1),
                 (Monitor2), 
                 (Printers),
                 (Adapter),
                 (MACAddress),
                 (DHCPEnabled),
                 (IPAddress),
                 (SubnetMask),
                 (Gateway),
                 (DNSPrimary),
                 (DNSSecondary),
                 (SCCMApps),
                 (ManualApps),
                 (Notes),
                 (TopConsoleUser),
                 (TCU_FirstName),
                 (TCU_LastName),
                 (TCU_Site),
                 (TCU_Dept),
                 (TCU_JobTitle),
                 (MgrFirstName),
                 (MgrLastName))
    
    I am getting "Invalid column name.." on each column name, so I'm sure it's just a syntax thing, but I'm not seeing it in the code.

    Wednesday, May 17, 2017 3:48 PM
  • You forgot all of the '$' signs.  The code in the SQL is NOT PowerShell.  It is T-SQL variable syntax.

    For consistency and reliability commas should always come at the end of the line and not at the beginning.

    Parens always break before the line and not on the next line lest they get lost:

    INSERT INTO [dbo].[Refresh](
                [ComputerName],
              
    [Model],
              
    [Autologon],

    You might get away with it this time but in the future it can byte you.


    \_(ツ)_/



    • Edited by jrv Wednesday, May 17, 2017 3:54 PM
    Wednesday, May 17, 2017 3:52 PM
  • Note that [dbo] is always a default unless you have defined the object in your schema.  [] are only required when spaces or other characters are in a name.

    You can use these but know why and how they are implemented.


    \_(ツ)_/

    Wednesday, May 17, 2017 3:56 PM
  • Wednesday, May 17, 2017 3:59 PM
  • I appreciate all the advice. Right now, I'm not getting any errors, but the data is not getting written into the table. I am trying to figure out the best way to walk through the script to see what's going on. Anyone have any suggestions?

    Brian

    Wednesday, May 17, 2017 8:03 PM
  • This is not even close to what I posted.

     
    	$sqlvars = (
    	"ComputerName = '$($ComputerName = $computerObj.ComputerName)'", "Model = $($Model = $computerObj.Model)'", "Autologon = '$($Autologon = $computerObj.Autologon)'",
    	"BCA = '$($BCA = $computerObj.BCA)'", "NewWNum = '$($NewWNum = $computerObj.NewWNum)'", "Description = '$($Description = $computerObj.Description)'",
    	"Status = '$($Status = $computerObj.Status)'", "RefreshDate = '$($RefreshDate = $computerObj.RefreshDate)'", "InstallTech = '$($InstallTech = $computerObj.InstallDate)'",
    	"Building = '$($Building = $computerObj.Building)'", "Floor = '$($Floor = $computerObj.Floor)'", "Dept = '$($Dept = $computerObj.Dept)'", "OS = '$($OS = $computerObj.OS)'",
    	"Monitor1 = '$($Monitor1 = $computerObj.Monitor1)'", "Monitor2 = '$($Monitor2 = $computerObj.Monitor2)'", "Printers = '$($Printers = $computerObj.Printers)'",
    	"Adapter = '$($Adapter = $computerObj.Adapter)'", "MACAddress = '$($MacAddress = $computerObj.MACAddress)'", "DHCPEnabled = '$($DHCPEnabled = $computerObj.DHCPEnabled)'",
    	"IPAddress = '$($IP = $computerObj.IPAddress)'", "SubnetMask = '$($SubnetMask = $computerObj.SubnetMask)'", "Gateway = '$($Gateway = $computerObj.Gateway)'",
    	"DNSPrimary = '$($DNSPrimary = $computerObj.DNSPrimary)'", "DNSSecondary = '$($DNSSecondary = $computerObj.DNSSecondary)'", "SCCMApps = '$($SCCMApps = $computerObj.SCCMApps)'",
    	"ManualApps = '$($ManualApps = $computerObj.ManualApps)'", "Notes = '$($Notes = $computerObj.Notes)'", "TopConsoleUser = '$($TopConsoleUser = $computerObj.TopConsoleUser)'",
    	"TCU_FirstName = '$($TCU_FirstName = $computerObj.TCU_FirstName)'", "TCU_LastName = '$($TCU_LastName = $computerObj.TCU_LastName)'", "TCU_Site = '$($TCU_Site = $computerObj.TCU_Site)'",
    	"TCU_Dept = '$($TCU_Dept = $computerObj.TCU_Dept)'", "TCU_JobTitle = '$($TCU_JobTitle = $computerObj.TCU_JobTitle)'", "MgrFirstName = '$($MgrFirstName = $computerObj.MgrFirstName)'",
    	"MgrLastName = '$($MgrLastName = $computerObj.MgrLastName)'")
    	try
    

    "ComputerName = '$($computerObj.ComputerName)'",

    Please take the time to create a simple two column table and test until you understand how this works.


    \_(ツ)_/

    Wednesday, May 17, 2017 8:07 PM
  • This is not even close to what I posted.

     
    	$sqlvars = (
    	"ComputerName = '$($ComputerName = $computerObj.ComputerName)'", "Model = $($Model = $computerObj.Model)'", "Autologon = '$($Autologon = $computerObj.Autologon)'",
    	"BCA = '$($BCA = $computerObj.BCA)'", "NewWNum = '$($NewWNum = $computerObj.NewWNum)'", "Description = '$($Description = $computerObj.Description)'",
    	"Status = '$($Status = $computerObj.Status)'", "RefreshDate = '$($RefreshDate = $computerObj.RefreshDate)'", "InstallTech = '$($InstallTech = $computerObj.InstallDate)'",
    	"Building = '$($Building = $computerObj.Building)'", "Floor = '$($Floor = $computerObj.Floor)'", "Dept = '$($Dept = $computerObj.Dept)'", "OS = '$($OS = $computerObj.OS)'",
    	"Monitor1 = '$($Monitor1 = $computerObj.Monitor1)'", "Monitor2 = '$($Monitor2 = $computerObj.Monitor2)'", "Printers = '$($Printers = $computerObj.Printers)'",
    	"Adapter = '$($Adapter = $computerObj.Adapter)'", "MACAddress = '$($MacAddress = $computerObj.MACAddress)'", "DHCPEnabled = '$($DHCPEnabled = $computerObj.DHCPEnabled)'",
    	"IPAddress = '$($IP = $computerObj.IPAddress)'", "SubnetMask = '$($SubnetMask = $computerObj.SubnetMask)'", "Gateway = '$($Gateway = $computerObj.Gateway)'",
    	"DNSPrimary = '$($DNSPrimary = $computerObj.DNSPrimary)'", "DNSSecondary = '$($DNSSecondary = $computerObj.DNSSecondary)'", "SCCMApps = '$($SCCMApps = $computerObj.SCCMApps)'",
    	"ManualApps = '$($ManualApps = $computerObj.ManualApps)'", "Notes = '$($Notes = $computerObj.Notes)'", "TopConsoleUser = '$($TopConsoleUser = $computerObj.TopConsoleUser)'",
    	"TCU_FirstName = '$($TCU_FirstName = $computerObj.TCU_FirstName)'", "TCU_LastName = '$($TCU_LastName = $computerObj.TCU_LastName)'", "TCU_Site = '$($TCU_Site = $computerObj.TCU_Site)'",
    	"TCU_Dept = '$($TCU_Dept = $computerObj.TCU_Dept)'", "TCU_JobTitle = '$($TCU_JobTitle = $computerObj.TCU_JobTitle)'", "MgrFirstName = '$($MgrFirstName = $computerObj.MgrFirstName)'",
    	"MgrLastName = '$($MgrLastName = $computerObj.MgrLastName)'")
    	try

    "ComputerName = '$($computerObj.ComputerName)'",

    Please take the time to create a simple two column table and test until you understand how this works.


    \_(ツ)_/

    Oops. My bad. I guess there were too many '$' and I got confused. Trying again. I did notice that the $sqlvars was empty, so I'm sure that was it, but I'll make sure.
    Wednesday, May 17, 2017 8:48 PM
  • I got the Insert to work, but when I manually change one of the column data, then try the Update query, it is not updating. Would the Update query be similar to the Insert query, as far as the $sqlvars is concerned?
    Wednesday, May 17, 2017 10:33 PM
  • SQL vars work the same in all scripts.  It s part of the script parser used by sqlcmd, osql, Invoke-SQlCmd

    You should post in the T-SQL forum to get more detailed help about how to write and execute SQL scripts.


    \_(ツ)_/

    Wednesday, May 17, 2017 11:39 PM
  • OK, so I posted in the T-SQL forum, but the issue is more of a syntax issue for the $sqlvars object. I can get the following to work:

    $sqlCmd = @"
    UPDATE [dbo].[Refresh]
    	SET [Site] = '`$(Site)'
    WHERE [ComputerName] = '`$(ComputerName)'
    "@
    	
    $sqlvars = @(
    		"ComputerName = $($computerObj.ComputerName)"
    		"Site = $($computerObj.Site)"
    	)

    However, the following won't work:
    $sqlCmd = @"
    UPDATE [dbo].[Refresh]
    	SET	[Model] = '`$(Model)',
       	    [Autologon] = '`$(Autologon)',
    		[BCA] = '`$(BCA)',
    		[NewWNum] = '`$(NewWNum)',
    		[Description] = '`$(Description)',
    		[Site] = '`$(Site)',
    		[OS] = '`$(OS)',
    		[Monitor1] = '`$(Monitor1)',
    		[Monitor2] = '`$(Monitor2)',
    		[Printers] = '`$(Printers)',
    		[Adapter] = '`$(Adapter)',
    		[MACAddress] = '`$(MACAddress)',
    		[DHCPEnabled] = '`$(DHCPEnabled)',
    		[IPAddress] = '`$(IPAddress)',
    		[Gateway] = '`$(Gateway)',
    		[DNSPrimary] = '`$(DNSPrimary)',
    		[DNSSecondary] = '`$(DNSSecondary)',
    		[SCCMApps] = '`$(SCCMApps)',
    		[ManualApps] = '`$(ManualApps)',
    		[Notes] = '`$(Notes)',
    		[TopConsoleUser] = '`$(TopConsoleUser)',
    		[TCU_FirstName] = '`$(TCU_FirstName)',
    		[TCU_LastName] = '`$(TCU_LastName)',
    		[TCU_JobTitle] = '`$(TCU_JobTitle)',
    		[MgrFirstName] = '`$(MgrFirstName)',
    		[MgrLastName] = '`$(MgrLastName)'
    	WHERE [ComputerName] = '`$(ComputerName)'
    "@
    
    $sqlvars = @(
    	"ComputerName = $($computerObj.ComputerName)",
    	"Model = $($computerObj.Model)",
    	"Autologon = $($computerObj.Autologon)",
    	"BCA = $($computerObj.BCA)",
    	"NewWNum = $($computerObj.NewWNum)",
    	"Description = $($computerObj.Description)",
    	"Site = $($computerObj.Site)",
    	"OS = $($computerObj.OS)",
    	"Monitor1 = $($computerObj.Monitor1)",
    	"Monitor2 = $($computerObj.Monitor2)",
    	"Printers = $($computerObj.Printers)",
    	"Adapter = $($computerObj.Adapter)",
    	"MACAddress = $($computerObj.MACAddress)",
    	"DHCPEnabled = $($computerObj.DHCPEnabled)",
    	"IPAddress = $($computerObj.IPAddress)",
    	"Gateway = $($computerObj.Gateway)",
    	"DNSPrimary = $($computerObj.DNSPrimary)",
    	"DNSSecondary = $($computerObj.DNSSecondary)",
    	"SCCMApps = $($computerObj.SCCMApps)",
    	"ManualApps = $($computerObj.ManualApps)",
    	"Notes = $($computerObj.Notes)",
    	"TopConsoleUser = $($computerObj.TopConsoleUser)",
    	"TCU_FirstName = $($computerObj.TCU_FirstName)",
    	"TCU_LastName = $($computerObj.TCU_LastName)",
    	"TCU_JobTitle = $($computerObj.TCU_JobTitle)",
    	"MgrFirstName = $($computerObj.MgrFirstName)",
    	"MgrLastName = $($computerObj.MgrLastName)"
    	)
    

    If I use Invoke-Sqlcmd, I don't get any error. It just doesn't update the table. I even tried using Invoke-Sqlcmd2, but if I use the following for $sqlvars:

    [System.Collections.IDictionary]$sqlvars = @{
    		"ComputerName" = $($computerObj.ComputerName)
    		"Model" = $($computerObj.Model)
    		"Autologon" = $($computerObj.Autologon)
    		"BCA" = $($computerObj.BCA)
    		"NewWNum" = $($computerObj.NewWNum)
    		"Description" = $($computerObj.Description)
    		"Site" = $($computerObj.Site)
    		"OS" = $($computerObj.OS)
    		"Monitor1" = $($computerObj.Monitor1)
    		"Monitor2" = $($computerObj.Monitor2)
    		"Printers" = $($computerObj.Printers)
    		"Adapter" = $($computerObj.Adapter)
    		"MACAddress" = $($computerObj.MACAddress)
    		"DHCPEnabled" = $($computerObj.DHCPEnabled)
    		"IPAddress" = $($computerObj.IPAddress)
    		"Gateway" = $($computerObj.Gateway)
    		"DNSPrimary" = $($computerObj.DNSPrimary)
    		"DNSSecondary" = $($computerObj.DNSSecondary)
    		"SCCMApps" = $($computerObj.SCCMApps)
    		"ManualApps" = $($computerObj.ManualApps)
    		"Notes" = $($computerObj.Notes)
    		"TopConsoleUser" = $($computerObj.TopConsoleUser)
    		"TCU_FirstName" = $($computerObj.TCU_FirstName)
    		"TCU_LastName" = $($computerObj.TCU_LastName)
    		"TCU_JobTitle" = $($computerObj.TCU_JobTitle)
    		"MgrFirstName" = $($computerObj.MgrFirstName)
    		"MgrLastName" = $($computerObj.MgrLastName)
    	)
    I get the same thing - no error but the table isn't getting updated. I had no problem getting the Insert to work, but I can't get the big sqlvars/sqlcmd combo to work. Please help.

    Friday, May 26, 2017 2:32 PM