Below is snippet of AWS Cloudformation template that I want to use PowerShell installing Web Server Windows Feature after create Windows Server 2012 R2 (64 bits). However, AWS Cloudformation succesfully create Windows Server 2012 EC2 instance but not install Web Server role.
"commands" : {
"1-install-roles" : {
"command" : { "Fn::Join" : [ "", [
"if not \"None\" EQU \"",
{ "Ref" : "Roles" },
"\" (powershell -Command \"Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature ",
{ "Ref" : "Roles" },
" -Restart\")"]]
}
},
Thank you for your guidance.
I suspect you obtained this from a cloudformation template example. I would suggest trying if it works with the AMI(s) that are in the template. If not you can use AMI's that already have IIS installed on them. That's what I am doing as a work around as I ran into the same issue.
UPDATE: I researched and tested more. The powershell command actually should be:
Add-WindowsFeature
not
Install-WindowsFeature
Here are the commands I ran in PowerShell to get the Add-WindowsFeature working as expected:
set-executionpolicy bypass
ImportSystemModules
Import-Module servermanager
Related
I do the following:
$url = 'https://oo.de/websites/it'
$sncred = Get-StoredCredential -Target PnPPS:SPCredentials
$Global:snPnPConn = Connect-PnPOnline -Url $url -Credentials $sncred -TransformationOnPrem -CurrentCredential -ReturnConnection
# Does run, but the next one gives 403-Error
Get-PnpList
Get-PnPList : Der Remoteserver hat einen Fehler zurückgegeben: (403) Unzulässig.
How can I debug this?
According to the Admin of my site, I do have full access rights on the Site.
I can open the site in browser.
All Help in Internet is to AzureAD(?!).
$snPnpConn:
>ConnectionType : O365
>InitializationType : Unknown
>Scopes :
>PSCredential :
>ClientId : 31359c7f-bd7e-475c-86db-fdb8c937548e
>ClientSecret :
>ApplicationInsights : PnP.PowerShell.ALC.ApplicationInsights
>Url : https://foo.de/websites/it
>TenantAdminUrl :
>Certificate :
>DeleteCertificateFromCacheOnDisconnect : False
>Context : PnP.Framework.PnPClientContext
>Tenant :
>AzureEnvironment : Production
I've run into the same problem. My solution was to Uninstall PnP.PowerShell module and install the legacy SharePointPnPPowerShell2019 module. The legacy module isn't being maintained, but the newer version doesn't support on-premise installations. There is some confusion about this, and there were attempts made to get PnP.PowerShell to work with on-prem (the -TransformationOnPrem flag). But Microsoft documentation as of May 2022 says that PnP.PowerShell doesn't support on-premise farms: PnP PowerShell.
From PowerShell, run "Uninstall-Module PnP.PowerShell". Once that completes, run "Install-Module SharePointPnPPowerShell2019" (or 2016 or 2013, depending on your version of SharePoint.
After I got the legacy module installed, I was able to successfully run commands like Get-PnPList without the 403 errors.
Team,
We are trying out this IOT remote monitoring suite from github. We are trying to first deploy that locally instead of Azure and hence we have followed the document mentioned here https://github.com/Azure/azure-iot-remote-monitoring/blob/master/Docs/local-deployment.md
Also, we have followed the pre-requisites over here https://github.com/Azure/azure-iot-remote-monitoring/blob/master/Docs/dev-setup.md
We then come over to my developer command prompt (running as admin) but we end up having error:
Get-AzureEnvironment : The 'Get-AzureEnvironment' command was found in
the module 'Azure', but the module could not be loaded. For more
information, r 'Import-Module Azure'. At
C:\Users\swagh\Downloads\azure-iot-remote-monitoring-master\azure-iot-re
-monitoring-master\Common\Deployment\PrepareIoTSample.ps1:14 char:14
+ if ((Get-AzureEnvironment AzureCloud) -eq $null)
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AzureEnvironment:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Get-AzureRMEnvironment : The 'Get-AzureRMEnvironment' command was
found in module 'AzureRM', but the module could not be loaded. For
more information, run 'Import-Module AzureRM'.
The modules has been imported successfully but not sure why it fails while building the soln locally. Tried setting the execution policy to bypass, unrestricted. Also scoped to the current user but its not helping.
We have run out of ideas. Can anyone help please?
According to your error message, it seems you have not install Azure PowerShell correctly.
We can install download Azure PowerShell here. After download azure-powershell.4.2.0.msi completed, run as administrator.
We can find latest version of Azure powershell here.
We can run this command in Azure PowerShell version 4.2.0:
Azure error
The screenshot for the above error.
I'm pretty new to Powershell and wanted to create a script that install the Remote Desktop Service which is a prerequisite of my application. (I'm on R2012 btw)
I already found that it's possible to do so with a domain account on a remote server (due to the restart needed during installation). I used:
New-RDSessionDeployment [-ConnectionBroker] <String> [-SessionHost] <String[]> [[-WebAccessServer] <String> ]
Now, I want to install RDS on my local server when I launch my Powershell script (as I can do with the Server Manager GUI). The goal is to install RDS and my application in the same Powershell script without the need to do it using a remote server.
Is it possible to do so ? Should I use the role-based RDS installation or is there any tricks I can use to bypass the local server restart (like maybe a workflow) ?
You just need to add the RDS Feature
Add-WindowsFeature –Name RDS-RD-Server –IncludeAllSubFeature -Restart
If you don't include -Restart the restart is not performed - but will be needed before the feature can be used.
Yes , on the context that you need to use New-SessionDeployment but having being said you still need the remotedesktop module to be imported first using
Import-Module RemoteDesktop
Now you need have RD Connection Broker, RD Web Access, and RD Session Host by using:
New-SessionDeployment –ConnectionBroker server.domain.com
–WebAccessServer server.domain.com –SessionHost server.domain.com
Now you need a Licensing Role, use:
Add-RDServer -Server server2.domain.com -Role RDS-LICENSING
-ConnectionBroker server1.domain.com
NOw we have use the deployment for the licensing , use :
Set-RDLicenseConfiguration -LicenseServer server2.domain.com -Mode PerUser
-ConnectionBroker server1.domain.com
Now you can use ,
New-RDSessionCollection and can publish New-RDRemoteapp
This should help you in proceeding further.
Short story: I get the following error when trying to create a namespace on Azure Service Bus using Azure Powershell (Run as Administrator):
PS C:> New-AzureSBNamespace -Name mynewnamespace2 -Location "East US"
-CreateACSNamespace $true -Namespac New-AzureSBNamespace : Object reference not set to an instance of an object. At line:1 char:1
+ New-AzureSBNamespace -Name mynewnamespace2 -Location "East US" -CreateACSNamespace $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureSBNamespace], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceBus.NewAzureSBNamespaceCommand
Long story: I created a first namespace in Azure Service Bus to use Relay in buffered mode (namespace=mynewnamespace). It works great except when you want to transfer a larger set of data. For this there is the streamed mode and I found this handy example (https://code.msdn.microsoft.com/How-to-send-a-large-c36ab70e), changed appropriate settings for namespace and credentials and ran the server part from the project and I get the error
{"The remote name could not be resolved:
'mynewnamespace-sb.accesscontrol.windows.net'"}
because, of course, this ACS namespace does not exist. So I found out that I need to create the namespace the old fashioned way using PS, installed Azure CLI and run the commands below with the following result:
For a list of all Azure cmdlets type 'get-help azure'.
For a list of Windows Azure Pack cmdlets type 'Get-Command wapack'.
PS C:> azure login
info: Executing command login
|info: To sign in, use a web
browser to open the page https://aka.ms/devicelogin. Enter the code EE226448L to
authenticate. If you're signing in as an Azure AD application, use the
--username and --password parameters.
/info: Added subscription Visual Studio Enterprise with MSDN info: Setting subscription
"Visual Studio Enterprise with MSDN" as default
info: login command OK
PS C:> New-AzureSBNamespace -Name mynewnamespace2 -Location "East US" -CreateACSNamespace $true -NamespaceType Messaging
WARNING: Microsoft Azure PowerShell collects data about how users use
PowerShell cmdlets and some pro encounter. Microsoft uses this
information to improve our PowerShell cmdlets. Participation is volu
choose to participate your device automatically sends information to
Microsoft about how you use Azure Powershell.
If you choose to participate, you can stop at any time by using Azure
PowerShell as follows:
1. Use the Disable-AzureDataCollection cmdlet to turn the feature Off. The cmdlet can be found in the AzureResourceManager module To disable
data collection: PS > Disable-AzureDataCollection
If you choose to not participate, you can enable at any time by using
Azure PowerShell as follows:
1. Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can be found in the AzureResourceManager module To enable
data collection: PS > Enable-AzureDataCollection
Select Y to enable data collection [Y/N]: WARNING: You choose not to
participate in Microsoft Azure PowerShell data collection. WARNING:
The setting profile has been saved to the following path
'C:\Users\PDube\AppData\Roaming\Windows Azure Powershell\AzureDataCollectionProfile.json'.
New-AzureSBNamespace :
Object reference not set to an instance of an object. At line:1 char:1
+ New-AzureSBNamespace -Name mynewnamespace2 -Location "East US" -CreateACSNamespace $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureSBNamespace], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceBus.NewAzureSBNamespaceCommand
I tried to create the new namespace using Azure CLI on 2 different computers, thinking the first install was corrupted, but I get the exact same error.
How can I fix this error?
When I run the following PowerShell script directly on a machine
Add-Type -Path "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Client.dll"
$basePath = "http://magv-dev-tfs:8080/tfs/MccCollection"
[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($basePath)
I get an objects, with the fields AuthenticatedUserName, AuthenticatedUserDisplayName, AuthenticatedUserIdentity set.
When I run the same script in a remote PowerShellTab from some other machine on the same machine using the sam e credentials, then these 3 fields are emply:
AuthenticatedUserName :
AuthenticatedUserDisplayName :
AuthenticatedUserIdentity :
Uri : http://my-tfs:8080/tfs/mcccollection
TimeZone : System.CurrentSystemTimeZone
InstanceId :
Name : my-tfs\MccCollection
Credentials : System.Net.SystemNetworkCredential
Culture : de-DE
SessionId : 7c76a150-f681-4b3c-9b0d-2836a3a5a908
ClientCacheDirectoryForInstance :
HasAuthenticated : False
TfsTeamProjectCollection : magv-dev-tfs\MccCollection
Edit:
At least I found a work around How to use [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer with credential from Powershell
Add a -credential argument to the invoke-command call?
When you use Visual Studio TFS, PowerShell can access the connections that you have registered when you connected to your project. RegisteredTfsConnections provides access to the registered connections, so you don't have to bother with putting your credentials into the code.
The following snippet connects to a TFS server, and returns a WorkItem.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client")
$regProjCollection = [Microsoft.TeamFoundation.Client.RegisteredTfsConnections]::GetProjectCollection("tfs2010\TFS2010-MyCollection")
$tfsTeamProjCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($regProjCollection)
$ws = $tfsTeamProjCollection.GetService([type]"Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore")
$ws.GetWorkItem(2525)