Error in executing powershell script SQL Server - powershell

I have a powershell script that am running but it keeps getting errors. Please see below:
Invoke-Sqlcmd : Could not load file or assembly 'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies
How can I fix this problem?
I have checked online for solution but could not get any help

I got solution from this page:
https://social.technet.microsoft.com/wiki/contents/articles/35832.sql-server-troubleshooting-could-not-load-file-or-assembly-microsoft-sqlserver-batchparser.aspx

Related

Get-MsalToken: The property 'Authority' cannot be found on this object

I am creating dashboard with Powershell Universal (https://docs.powershelluniversal.com/userinterfaces/dashboards) and I am trying to get an access token in order to connect to MS Graph. I am using the command Get-MsalToken (part of the MSAL.PS module) to get an access token. The code I am running is below:
$Params = #{
ClientId = $Credential.UserName
ClientSecret = $Credential.Password
TenantId = 'xxxxxxxxxxxxxxxxxxxx'
ForceRefresh = $true
ErrorAction = 'Stop'
}
$AccessToken = (Get-MsalToken #Params).AccessToken
When running the above code on the command line using Powershell 7, it works fine. However when the dashboard runs the same command on Powershell 7, it returns this error message:
Get-MsalToken: The property 'Authority' cannot be found on this object. Verify that the property exists.
The module MSAL.PS is on version 4.37.00 on both my local instance and on the server where the dashboard is running from. For the most part I am unable to replicate the error on the command line on either my machine or on the server, and the command works perfectly. I was able to reproduce the error locally on my machine's command line after connecting to other services and then running Get-MsalToken, but trying this a second time is getting the access token correctly, so I am unable to accurately reproduce the error on the command line. The dashboard however is consistent with this error. Running an automated script from the server also does not produce the error.
I did see a forum on github about this same issue, but there is no clear resolution. I did see people recommending commenting out some lines from the source code, but given that they recommend commenting out a line for TenantID, which I am using for the connection, I am not in favor of doing that. The forum can be found here: https://github.com/AzureAD/MSAL.PS/issues/45
I was just wondering if anybody else has run into this issue or knows of a solution or alternative. Thanks!
As NiMux stated above, the solution is to simply import the MSAL.PS module before importing anything else. At the top of the main page of my code I simply added Import-Module -Name MSAL.PS -Force and I got it to work properly. Even though the module was already installed and imported, it needs to be imported before anything else.
Hopefully this helps somebody else with this issue in the future.

Powershell DSC - MSFT_RoleResource

I have a problem related to MSFT_RoleResource, I have recovered a DSC script that you can find below:
The compilation in .mof works as shown below:
Once the compilation is finished I want to make an Azure policy, the compilation works as shown below ( it's very strange because when i compile the script i have error who say replace the PSDesiredStateConfiguration By PSDresource):
I want to test it afterwards but it sends me this error:
Can you help me?
Thank you so much
I tried to redo the manipulation on a blank machine, uninstall Powershell 7 and reinstall .

Start-Process : The system cannot find the file specified from TeamCity Build step but works fine locally

i am trying to run Pact broker can i deploy tool with paramaters which is working fine locally but when i add the build step in TeamCity it is throwing below error
Start-Process : This command cannot be run due to the error: The
system cannot find the file specified.
when i run the same powershell script locally, it is working fine .
powershell script:
CanIDeploy.bat code is
Note: the reason i am calling pact-broker.bat from power shell script is, unable to run bat file from Teamcity , that is the reason created powershell script which internally calls pact broker bat file.
any help is appreciated
I see that you use relative path, but what about the working directory? I see a different path in the error message vs what you show where the file is.

IBM RFT command line execution -datastore -playback parameter

I need to start my RFT scripts with a .bat script. I tried this with:
"%IBM_RATIONAL_RFT_INSTALL_DIR%\rational_ft.exe" -datastore "C:\project" -playback "test"
In the .bat file. With a test project in C:\project and a test script named test.java.
When I start the batch file, RFT opens a playback window and is looking for the script. But I always receive a error:
[Rational.Test.Ft.Application.ScriptPlaybackException: Could not get type for [test].
I found out that this must be a problem with the path of the test script.
But I still don't know what is going on, the path is correct and I tried everything without a positive result. RFT playback starts, but still cant find this script.
I hope anybody can help me. Thanks in advance.
Using the command you tried to start RFT I get the same error. I don't know what the rational_ft.exe is for, but it works when you don't call this but the java.exe with the class com.rational.test.ft.rational_ft:
"%IBM_RATIONAL_RFT_ECLIPSE_DIR%\jdk\jre\bin\java" -classpath "%IBM_RATIONAL_RFT_INSTALL_DIR%\rational_ft.jar" com.rational.test.ft.rational_ft -datastore C:\project -playback Test
See this IBM developerWorks article for more information.

Why I get other result for the `get-Help about_*` expression?

PowerShell 4.0
I read the Getting Started with PowerShell book. I try author's code but I get the other result... The screen of the book page (with my comment):
Read my comment on the screen, please. I get such results:
Why I get other results?
I have seen this same issue on several machines. Update-Help appears to execute successfully when run from a normal PowerShell window, but does not actually update many of the help files.
The solution is to run Update-Help from an elevated PowerShell window (Run as Administrator). Once this completes you should have all of the expected help files.
You may also have to specify the -UICulture parameter since Update-Help may not be utilizing your localization settings as seen in this post.
You can use this command to update help for your language:
Update-Help -UICulture (Get-Culture).Name
I found the reason of my problem...
I had launched Updated-Help with admin rights, of course, but I didn't restart the PowerShell session and got that unexpected result. Later I restarted PowerShell and saw that all works fine after restarting.
I didn't think that application restarting can be necessary at this case.