Creating computer objects without accessing ARS console - powershell

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.

Related

PowerShell PackageManagement - How to uninstall a package provider?

Troubleshooting i tried uninstalling nuget. NuGetProvider-2.8.5.208.dll to be specific.
I have never worked with Power Shell before and am totally lost.
I found this question that helped me find nuget and create a command to delete it.
But I'm unable to follow through.
I did start powershell as administrator.
Here the input:
(Get-PackageProvider|where-object{$_.name -eq "nuget"}).ProviderPath|Remove-Item -force Restart-Computer
The error message:
Remove-Item : The input object cannot be bound to any parameters of the command because the command does not accept pipeline input or the input and its properties do not match any of the parameters that accept pipeline input.
and its properties do not match any of the parameters that accept pipeline input.
line:1 character:70
+ ... _.name -eq "nuget"}).ProviderPath|Remove-Item -force Restart-Computer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (C:\Users\XXX ...GetProvider.dll:String) [Remove-Item], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.RemoveItemCommand
How can i solve this and successfully uninstall it?
Thanks for your answer!
Still no luck. Here the error:
Remove-Item : The element C:\Users\XXX\AppData\Local\PackageManagement\ProviderAssemblies\nuget\2.8.5.208
\Microsoft.PackageManagement.NuGetProvider.dll cannot be removed: Access to the path "C:\Users\XXX\AppData\Local\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvide
r.dll" denied.
Line:1 Character:44
+ (Get-PackageProvider NuGet).ProviderPath | Remove-Item -Force
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\Users\XXX ...GetProvider.dll:FileInfo) [Remove-Item], Unauthoriz
edAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand

Installing CCM client on PC via powershell

I'm trying to speed up how soon SCCM recognises a device on the domain and starts the process of installing applications.
I have the below in powershell
$CCMInstallerPath = "\\ServerFQDN\SMS_MAN\Client\ccmsetup.exe"
$args = "/mp:MPServer", "/LOGON", "/UsePKICert", "SMSSLP=SMSSLPServer", "SMSSITECODE=MAN"
& $CCMInstallerPath $args
I get the below error:
Program 'ccmsetup.exe' failed to run: Access is deniedAt line:1 char:5
+ & $CCMInstallerPath $args
+ ~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:5
+ & $CCMInstallerPath $args
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
I have read and execute access to this file, both by group and directly by name
I have also tried:
Start-Process -FilePath \\ServerFQDN\SMS_MAN\Client\ccmsetup.exe -ArgumentList "/mp:MPServer", "/logon SMSSITECODE-MAN", "/UsePKICert"
and get the error
Start-Process : This command cannot be run due to the error: Access is denied.
At line:1 char:5
+ Start-Process -FilePath \\ServerFQDN\SMS_MAN\Client\c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
ServerFQDN is a replacement for one of our NM servers
I can fully connect to the folder and run the exe manually
I am running elevated powershell
Issue was caused by incorrect share permissions found in effective access.
Permission was granted to run the file but effective access was showing differences

Exchange Online - Powershell cmdlet "New-MailboxImportRequest" not accepting "FilePath" parameter

When I am using the cmdlet New-MailboxImportRequest, it is not accepting the -FilePath parameter. And when I remove the parameter it complains that it is required! I'm sure there is a quick explanation for this. Any ideas?
Some details:
PowerShell version 6.2.1(also tried in PowerShell 5.1)
Connecting to O365 using URI https://outlook.office365.com/powershell-liveid/
I have given myself the "Mailbox Import Export" role necessary for running this cmdlet.
I am able to run Get-MailboxImportRequest without issue
With FilePath it complains:
PS C:\> New-MailboxImportRequest -Mailbox "Archive Mailbox" -FilePath "D:\testuser.pst" -TargetRootFolder "RecoveredFiles" -IncludeFolders "#Inbox#"
A parameter cannot be found that matches parameter name 'FilePath'.
+ CategoryInfo : InvalidArgument: (:) [New-MailboxImportRequest], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,New-MailboxImportRequest
+ PSComputerName : outlook.office365.com
Without FilePath it complains:
PS C:\> New-MailboxImportRequest -Mailbox "Archive Mailbox" -TargetRootFolder "RecoveredFiles" -IncludeFolders "#Inbox#"
Cannot process command because of one or more missing mandatory parameters: FilePath.
At C:\Users\<redacted>\AppData\Local\Temp\tmp_n11tq1ct.qbd\tmp_n11tq1ct.qbd.psm1:44229 char:9
+ $steppablePipeline.End()
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-MailboxImportRequest], ParameterBindingException
+ FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.Exchange.Management.Migration.MailboxReplication.MailboxImportRequest.NewMailboxImportRequest
EDIT: I re-read the Microsoft documentation and noticed that for "FilePath" it states that "This parameter is available only in on-premises Exchange." Which makes this even more confusing. If its only available in on-prem, why is it a required parameter for Exchange Online? If it's not a valid parameter for Exchange Online, why even have this PowerShell command available in EXO?
https://learn.microsoft.com/en-us/powershell/module/exchange/mailboxes/new-mailboximportrequest?view=exchange-ps

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.

Unable to Use Windows Update COM object in RemotePS sessions

Im trying to change the windows update settings in a remote server using powershell, but when i run the below commands it gives me an error.
PS C:\Windows\system32> Enter-PSSession opalisbinary
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.NotificationLevel=2
Property 'NotificationLevel' cannot be found on this object; make sure it exists and is settable.
At line:1 char:14
+ $AUSettings. <<<< NotificationLevel=2
+ CategoryInfo : InvalidOperation: (NotificationLevel:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.IncludeRecommendedUpdates=$true
Property 'IncludeRecommendedUpdates' cannot be found on this object; make sure it exists and is settable.
At line:1 char:14
+ $AUSettings. <<<< IncludeRecommendedUpdates=$true
+ CategoryInfo : InvalidOperation: (IncludeRecommendedUpdates:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.Save()
You cannot call a method on a null-valued expression.
At line:1 char:18
+ $AUSettings.Save <<<< ()
+ CategoryInfo : InvalidOperation: (Save:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Although when i run it locally on the server it works fine...
Could anyone please help me.
Does it work when you connect via Remote desktop and run the commands? It also depends on the bittnes. I don't know the Microsoft.Update.AutoUpdate, so I'm just guessing, but - is it available for x64 version of PowerShell? In other words if you run it locally in x64 version and x86, do you see the errors?
I am sorry, I could not find a real answer. What I found is this link which states that remote PS sessions can be used with SCCM 2012, but they could not with SCCM 2007.
This does not help you, but it seems that not all COM objects are compatible with remote PS sessions.