Error when using Connect-MsolService username and password - powershell

Why I get this error when trying to use this command Connect-MsolService
Connect-MsolService : The user name or password is incorrect. Verify your user name, and then type your
password again.
At line:1 char:1
+ Connect-MsolService
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+ FullyQualifiedErrorId : 0x80048821,Microsoft.Online.Administration.Automation.ConnectMsolService
The user that I am trying to login with is a global admin.

Did you add your credential object to the cmdlet, because it does not do native passthrough if your currently logged in user.
For example Connect-MSOLOnline -Credential (Get-credential)

Related

Powershell Invoke-cmd to connect remote machine SQL Server with credentials not working

Powershell Invoke-cmd to connect to SQL Server on a remote machine with credentials is not working.
Enter-PSSession command is executed which successfully connects the remote machine.
$sqlpassPowershell = ConvertTo-SecureString "sqluserpass" -AsPlainText -Force
Invoke-Sqlcmd -Query "SELECT QUERY" -ServerInstance "sqlinstanename" -User "sqlusername" -Password $sqlpassPowershell
Even though the credentials are correct, I get this error:
Instance "MachineName" -User "psUser" -Password $sqlpass
Invoke-Sqlcmd : Login failed for user 'psUser'.
At line:1 char:1
+ Invoke-Sqlcmd -Query "Select query" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlException
+ FullyQualifiedErrorId : SqlExectionError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
Invoke-Sqlcmd :
At line:1 char:1
+ Invoke-Sqlcmd -Query "SELECT query" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], ParserException
I tried
Install-Module SqlServer, dbatools, SqlPS
Import all modules
I still get the same error.
If I didn't provide any instance and username, password then it works fine.
Any other solution. I need to figure out this thing as soon as possible. Need to move further on this.

Creating computer objects without accessing ARS console

I want to create computer objects without accessing the ARS console
powershell.exe -command New-QADComputer -Name <Name of the new computer> -ParentContainer "<OU-Copied the distinguishedName of an earlier computer object from the AD>" -ObjectAttributes #{edsajoincomputertodomain='domain\userID'}
I am getting the below error while executing the above command.
New-QADComputer : Cannot convert 'System.Object[]' to the type 'ActiveRoles.ManagementShell.Data.IdentityParameter'
required by parameter 'ParentContainer'. Specified method is not supported.
At line:1 char:49
+ ... ntContainer <OU> ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-QADComputer], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,ActiveRoles.ManagementShell.Powershell.Cmdlets.NewComputerCmdlet
Note: We need to use the same credential which we used to add the computer object in AD to join the client computer to Domain.

Connecting Skype for Business with ChatBot

I am trying to deploy Bot on skype and facing this error,
Could anyone please suggest the solution for the same:
PS C:\WINDOWS\system32> $TenentAdminDomainId = Read-Host -Prompt 'Input your domain id in <user>#<domain>.com'
Input your domain id in <user>#<domain>.com: test2#botwork.onmicrosoft.com
PS C:\WINDOWS\system32> New-CsOnlineApplicationEndpoint -ApplicationId fc1d28c4-7ff2-41dd-9a1b-a5652949d051 -Name TestBotAP -Uri sip:$TenentAdminDomainId
Cmdlet invocation error
+ CategoryInfo : NotSpecified: (:) [New-CsOnlineApplicationEndpoint], CmdletInvocationException
+ FullyQualifiedErrorId : Error processing cmdlet request,Microsoft.Rtc.Management.Hosted.PlatformService.NewPlatformServiceAppEndpointConfigCmdlet
+ PSComputerName : adminin1.online.lync.com
Could not find the application endpoint
+ CategoryInfo : InvalidOperation: (Microsoft.Rtc.M...cation endpoint:PlatformServiceCmdletException) [New-CsOnlineApplicationEndpoint], PlatformServiceException
+ FullyQualifiedErrorId : Could not get application endpoint or the Uri is already present as an User in BVD,Microsoft.Rtc.Management.Hosted.PlatformService.NewPlatformServiceAppEndpointConfigCmdlet
+ PSComputerName : adminin1.online.lync.com
From https://learn.microsoft.com/en-us/skype-sdk/skype-for-business-bot-framework/docs/bot-common-errors
FullyQualifiedErrorId : Could not get application endpoint or the Uri
is already present as a User in BVD
Delete the existing user account with the same sipuri in tenant, or
run the cmdlet using a sipuri that does not already exist in the
tenant.

Remote server login error

Hi I want to login into my remote server using power shell . I wrote code for this but I am getting error .
CODE
$cred = get-credential - Prompts for username and password
Enter-PSSession -ComputerName servername -Credential $cred
ERROR
Get-Credential : A positional parameter cannot be found that accepts
argument 'Prompts'.At C:\documents\Untitled8.ps1:1 char:9
+ $cred = get-credential - Prompts for username and password
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Credential], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetCredentialCommand
Enter-PSSession : Connecting to remote server XXXXX failed with the
following error message : Access is denied. For more information, see
the about_Remote_Troubleshooting Help topic.At
C:\documents\Untitled8.ps1:5 char:1
+ Enter-PSSession -ComputerName servername -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (servername:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Any clue regarding this will help....
Get-Credential : A positional parameter cannot be found that accepts argument 'Prompts'
Anybody have any clue how to login into remote server in power shell using servername..any clue any link regarding this will be helpful
The problem is that there it canĀ“t find a positional parameter, where "Prompts" is accepted. If you look at the help file for Get-credential you will see that the -Credential paramenter is positional, meaning you dont need to type it.
Try with this
$cred = get-credential -Message "Prompts for username and password"
Enter-PSSession -ComputerName servername -Credential $cred
Some reading about positional parameters
https://itknowledgeexchange.techtarget.com/powershell/positional-parameters/

Azure AD - Powershell -Federation Metadata Url is missing for federated user

I am trying to Access my Azure AD using Powershell I am getting the below error
Powershell Error screenshot as below
Any one please help me to understand why i am getting this error.
Thanks in advance.
Error Message :
PS C:\Users\YYYYY> Connect-MsolService -Credential $password
Connect-MsolService : Authentication Error: Unable to complete
authentication request (potentially a proxy issue) At line:1 char:1
+ Connect-MsolService -Credential $password
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.Online.Administration.Automation.ConnectMsolService