'Set-AdfsGlobalWebContent' is not recognized as the name of a cmdlet - powershell

I am trying to change company name using 'Set-AdfsGlobalWebContent' of powershell 4.0 .
I am using power-shell ISE but I am not able to get this command.
I am working on windows server 2012 R2
Anybody explain me Why that command is not showing in intelligence? is I am missing something?
after executing this command forcefully it gives "'Set-AdfsGlobalWebContent' is not recognized as the name of a cmdlet" error.
Thanks in Advance !!!

From technet:
To use these cmdlets you must have previously installed the AD FS server role. This can be done using the Add Roles and Features Wizard in Server Manager or optionally, you can use the Install-WindowsFeature AD-Federation-Services cmdlet at a Windows PowerShell prompt to add the role.

Related

Auto Answer Powershell Prompts from Scripts

I have written a powershell script which uses a third party Cmdlet (https://www.powershellgallery.com/packages/OdooCmdlets/21.0.8137.1).
The script is working fine on my local enviroment, but i need to apply it to an Azure Function to generate a daily execution (since it process data into a Azure SQL Database).
On its first line (see script below), i have establish the connection parameters where a prompt / pop-up window appears, which is easy to anwser when via user interaction from a local enviromnt (Powershell ISE)
However, when i try to run the script on the azure function the following error appears:
ERROR: A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: Would you like to install a license now? (You may use "TRIAL" as the Product Key to activate a trial license.)
I need to adapt the script in order to auto-anwser the prompt / pop-up window, or find another solution.
Powershell Script:
Import-Module OdooCmdlets
$odoo = Connect-Odoo -User 'xxxxx' -Password 'xxxx' -URL 'xxxxx' -Database "xxxx"
I've never used the cmdlets before but inspecting the help files: https://www.powershellgallery.com/packages/OdooCmdlets/21.0.8137.1/Content/lib%5Cnet20%5CCData.OdooCmdlets.Commands.dll-help.xml it appears there is an -RTK parameter available.
Is it possible you have a key which you can pass as part of the connection which would suppress the prompt?
Failing that, the developer docs have examples for Python which you could either translate to PowerShell and not use the Cdata Odoo module or just use python in your Azure Functions
https://www.odoo.com/documentation/15.0/developer/misc/api/external_api.html

Is it possible to delete or overwrite cmdlets?

I'm working with DNS resource records in Powershell 5 using code that I inherited from the guy who was trying to do this before me. The cmdlet I am trying to use is Add-DnsServerResourceRecordA.
Part of his code has import-module certain folder\PowerShell\Modules\DnsServer. The weird thing is, it seems like as I was trying bits and pieces of the code earlier, I was able to use the add-DNSblah cmdlet. Now, after It ried running the whole script including the import-module, Powershell is saying that the cmdlet does not exist natively, and when I import the module and run it it is giving me Add-DnsServerResourceRecordA: Invalid Class.
It is my understanding that Add-DnsServerResourceRecordA should be included in my normal Powershell 5.0. Could that Import-Module have permanently damaged PS somehow? Why else would the cmdlet not show up, even in a Get-Command "dns"?
I'm pretty sure you will need the Remote Server Administration Tools (RSAT) installed to have these cmdlets available on a non-server Windows OS.
You can download them from this page: https://www.microsoft.com/en-gb/download/details.aspx?id=45520.
Not really sure why the Import-Module does not fail if the DNSServer module is not present on the system.
If RSAT are already installed, you can try to reinstall them.

'Invoke-Sqlcmd' is not recognized as the name of a cmdlet

We have recently started using SQL Server 2012 SP3 and building the SQL server 2012 using a PowerShell script. There is a requirement in our automation process to run multiple database scripts on a db and I have found Invoke-Sqlcmd very reliable until I found this issue.
When I run Invoke-sqlcmd with a proper set of parameters in PowerShell's debug mode on the system on which the SQL server is installed recently, I don't have problem.
PowershellCommand   : Invoke-Sqlcmd -InputFile $sStrJBSPExecRolePath -ServerInstance $sStrSQLName -ErrorAction Stop
But when I execute same query through a PowerShell automation script after rebuilding the same server, I end up getting below error 
The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I did research online many suggested to Import SQLPS, etc., so for testing I added the below command in my script
get-pssnapin -Registered
Import-Module “sqlps” -DisableNameChecking**
Even after adding the above into the script, I still end up with same error. But when I run the same script manually it runs perfectly fine. I don't understand what is wrong.
PowerShell automation script - This script installs the .Net Framework 3.5, SQL Server 2012, SQL Server 2012 SP3, and then loads the SMO assembly that I use to change SQL settings such as the Max Memory limit of SQL.
Open up PowerShell as an Administrator and install the sqlserver module by Install-Module sqlserver
After the module has installed, the module commands including the Invoke-sqlcmd should be readily available.
You can check the same using Get-Command -Module sqlserver.
If this module is not readily available, you can Import-Module sqlserver after installing it.
This is not a complete solution, but just a work around which is working for me.
When you execute the query from automation the user which is executing that is not having access to the sqlcmd. Execute you command for the directory where your sqlcmd.exe is present.
Just put
CD "C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn".
to get the location for sqlcmd search the location for SQLCMD.exe in the search box.
if not found, you need to install that where it is missing, but in your case I think it is present, you just need to get the location right.
Also you will need set the path variable for the user executing the automation script or else it will only recognize the sqlcmd, but wont execute that.
$env:Path += ";C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\"
you can get this path from you local user for which it is working by $Env:Path

Unable to set the permissions of an app through PowerShell

I've been trying to set the permissions of a native application added through PowerShell with no success.
I'm following the instructions on this page:
https://msdn.microsoft.com/en-us/library/azure/dn790557.aspx
I can add the application through PowerShell (step #1), but when I try to set the permissions (step #2) I get several issues.
If I use the Microsoft Active Directory Module PowerShell, I am able to connect but when trying to select a subscription (with the correct values), the result is that the subscription does not exist. Out of curiosity, if I execute the Get-Subscription cmdlet I get an empty output. Even if I go ahead and issue the New-AzureRoleAssignment cmdlet, I get the Object reference not set to an instance of an object error.
If I use the Azure PowerShell, I am not able to issue the Connect-MsolService cmdlet since it says that the cmdlet is not found. Even though, if I go ahead and try the New-AzureRoleAssignment cmdlet, I get the same error as above.
Someone knows what am I doing wrong or if I'm missing a step?
Launch the Azure Powershell Console and use Import-Module <moduleName> for the module containing Connect-MsolService.
If you are using this combination of modules frequently, I would recommend to put that Import-Module command in the default profile for that console. I do not know how to do this, but google should.

Access Exchange shared folder via powershell

I need to access a public Exchange folder from my machine using PowerShell. I've found a guide saying that Get-PublicFolder is what I need, but I get this error:
The term 'Get-PublicFolder' is not recognized as a cmdlet, function, operable program, or script file. Verify the term
and try again.
Another guide suggests to add the exchange management snapin before calling it
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
but again i get no luck as it is not installed on my PC. So, what's the easiest way to cccess a public Exchange folder via PowerShell? Thanks
If your machine and the Exchange server have PowerShell v2 remoting enabled then you can create a remote session to the server and work as if you were locally on the Exchange box. Otherwise, you need to install the Exchange admin tools on your machine.