hello all ,
i am trying to execute the powershell script which is converting the excel file to .csv file from
SQL management studio. i am using xp_cmdshell .please help.
i cannot use execution Policy as Unrestricted .bcz of security issues.
please let know any idea where i am missing anything below is the error.
New-Object : Retrieving the COM class factory for component with CLSID
{00000000-0000-0000-0000-000000000000} failed due to the following error:
80040154 Class not registered (Exception from HRESULT: 0x80040154
(REGDB_E_CLASSNOTREG)).
At \11.1\Public$\DBA\Content\DEV\PtoS.ps1:101 char:12
- $ExcelWb = New-Object -ComObject excel.application
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : ResourceUnavailable: (:) [New-Object], COMExcept
ion
- FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Comman
ds.NewObjectCommand
The property 'DisplayAlerts' cannot be found on this object. Verify that the
property exists and can be set.
At \11.2.1\Public$\DBA\Content\DEV\PtoS.ps1:103 char:1
- $ExcelWb.DisplayAlerts=$False
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At \11.1\Public$\DBA\Content\DEV\PtoS.ps1:105 char:1
- $Workbook = $ExcelWb.Workbooks.Open(($InputFilePath + $InputFile))
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At \11.1\Public$\DBA\Content\DEV\PtoS.ps1:107 char:1
- $Workbook.SaveAs($OutputFileFullName,62) # UTF8 format csv
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At \11.1\Public$\DBA\Content\DEV\PtoS.ps1:113 char:1
- $WorkSheet = $WorkBook.Sheets.Item(1)
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At \11.1\Public$\DBA\Content\DEV\PtoS.ps1:117 char:1
- $Workbook.Close($False)
- ~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At \11.1\Public$\DBA\Content\DEV\PtoS.ps1:119 char:1
- $ExcelWb.Quit()
- ~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
NULL