Can I access IIS on a Windows Server 2016 remotely? - windows

I have to start and stop the sites after they are automatically updated. For now this requires me to Remote Desktop Connection to the server and start and stop them manually. I would like to be able to connect to the server through the command prompt and start and stop specific sites. I believe AppCmd can start and stop sites easily, but how should I connect to the server?

According to your description, I suggest you could use powershell WinRM to achieve your requirement.
You could use WinRM to remote access the server, the you could run the powershell command to manage the IIS application.
You should firstly enable the WinRM to allow remote management in the server side by using below powershell command:
#Get the winrm service status
Get-Service WinRM
#Allow remote access
Enable-PSRemoting –Force
#Quick config the winrm
winrm quickconfig
#Add all clients to trustedhosts
Set-Item wsman:\localhost\client\trustedhosts *
Restart-Service WinRM
In the client server, you could run below command:
#Connect to remote server
Enter-PSSession -ComputerName {yourremoteserver ip address or computer name} -Credential {accont name}
If you succeess, you will see the powershell window as below:
Then you could use below command to stop or start the application pool:
import-module WebAdministration
Stop-WebAppPool -Name 'DefaultAppPool'
or
import-module WebAdministration
Start-WebAppPool -Name 'DefaultAppPool'

Related

WSL intergration with ADS login credentials

I've installed WSL ubantu flavor, Installed Ansible and sutable linux packages on it. Thought of running the playbook from WSL by passing our organization hosts details in hosts file of ansible. But WSL(ubantu) login is not configured with our ADS credetails to execute passwordless ssh. But WSL is installed in oganization network. How we can achive this intergration
I tried with gateway host which establish passwordless ssh to connect respective hosts which is defined in ansible hosts file. similar way trying to achive from WSL, created proxy to bypass the connection. But ADS login is blocker for this.
Invoke-WebRequest -Uri https://aka.ms/wsl-debian-gnulinux -OutFile distro.zip -UseBasicParsing
Expand-Archive distro.zip debian
cd distro
.\debian.exe (edited)

Can't use WinRM client from specific server

I'm trying to use invoke-command from a Windows 2019 server (server A) to another Windows server (server B). I know WinRM is configured on server B because I am able to successfully use invoke-command from my workstation to server B. However when I try the same exact command with the same credentials from server A to server B it fails with the below error message. It fails so quickly that it seems like it's not even trying to reach out over the network.
Things I have tried so far:
Set trusted hosts on both servers using winrm s winrm/config/client #{TrustedHosts="*"}
Did a packet trace on our router to ensure packets on 5985 were allowed
Disabled the firewall on server A
Ran "winrm quickconfig" on both servers
The command I'm using to test is invoke-command -computername "server B" {1}.
I'm able to successfully ping server B from server A.
Any thoughts on what could possibly be causing this?

Docker instalation failed on windows server 2016 datacenter

I'm trying to install docker at this VM
But I'm getting the following error:
According to this documentation, windows server 2016 datacenter does support docker.
Also in the microsoft site, at least for the 2019 it is specified that containerization it is supported, is there a different version for this OS?
As per the documentation, the problem seems to be Docker Desktop, according to this article Build and run your first Docker Windows Server container, for Windows server you need to execute the installation through the command line:
Once Windows Server 2016 is running, log in, run Windows Update to ensure you have all the latest updates and install the Windows-native Docker Engine directly (that is, not using “Docker for Windows”). Run the following in an Administrative PowerShell prompt:
Install-Module -Name DockerMsftProvider -Force
Install-Package -Name docker -ProviderName DockerMsftProvider -Force
Restart-Computer -Force
Docker Engine is now running as a Windows service, listening on the default Docker named pipe. For development VMs running (for example) in a Hyper-V VM on Windows 10, it might be advantageous to make the Docker Engine running in the Windows Server 2016 VM available to the Windows 10 host:
Open firewall port 2375
netsh advfirewall firewall add rule name="docker engine" dir=in action=allow protocol=TCP localport=2375
Configure Docker daemon to listen on both pipe and TCP (replaces docker --register-service invocation above)
Stop-Service docker
dockerd --unregister-service
dockerd -H npipe:// -H 0.0.0.0:2375 --register-service
Start-Service docker
The Windows Server 2016 Docker engine can now be used from the VM host by setting DOCKER_HOST:
$env:DOCKER_HOST = "<ip-address-of-vm>:2375"

bootstrap windows winrm fails with network error

I am trying to bootstrap a windows winrm using knife command.
I have enabled the tcp port 5985.
But i still get the following error:
ERROR: Network Error: Connection refused - connect(2) (http://:5985)
I am able to remotely login to the machine as well by providing username and password
I could not resolve. Has anyone come across this problem and found a solution?
Check that you can telnet remote_host 5985. This should open a dumb session into which you can enter "quit". If not, look again at how you have enabled winrm and the firewall on the remote host.
I got winrm bootstrap working on Windows VMs which did not have firewall enabled like this:
All the following on the remote Windows machine you want to bootstrap...
Enable winrm:
winrm quickconfig -q
Enable and start the firewall service (so we can successfully config winrm):
sc config mpssvc start= demand
sc start mpssvc
Configure winrm per chef recommendations:
winrm set winrm/config/winrs #{MaxMemoryPerShellMB="300"}
winrm set winrm/config #{MaxTimeoutms="1800000"}
winrm set winrm/config/service #{AllowUnencrypted="true"}
winrm set winrm/config/service/auth #{Basic="true"}
Stop the firewall service again:
sc stop mpssvc
... or configure it to allow to winrm connections from the workstation.
Now, on your workstation, validate the set up:
Validate that remote host is listening on default winrm port
telnet remote_host 5985
(If connection is successful, a blank telnet session will open. You can enter "quit" to exit it.)
Optionally validate that knife winrm can connect to the remote host (e.g. to list the c:\ directory)
knife winrm -m remote_host -x remote_user -P remote_password 'dir c:\'
Bootstrap the node
knife bootstrap windows winrm remote_host -x remote_user -P remote_password
Since you ask for an answer drawing from credible and/or official sources here are the references I found useful when figuring out how to get winrm bootstrap to work:
http://docs.opscode.com/install_windows.html
http://docs.opscode.com/plugin_knife_windows.html
http://developer.rackspace.com/blog/step-by-step-walkthrough-to-using-chef-to-bootstrap-windows-nodes-on-the-rackspace-cloud.html
I have faced the similar issue.One of the reasons for this might be you knife-windows gem is not installed in expected location.
knife-windows resolves target hostname.if its not properly installed winrm knife cant resolve targetname.So to overcome this install knife-windows as below
To install the knife windows plugin using RubyGems, run the following command:
$ /opt/chef/embedded/bin/gem install knife-windows
if properly installed you should be able to find knife-windows at /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/

Unable to bootstrap with winrm

when i run
knife bootstrap windows winrm <my ec2 fqdn> -x Administrator -P "<password>" -r "role[myrole]"
my instance is inside vpc and i have attached eip In place od i gave both my private ip and public ip
ERROR: Batch render command returned
ERROR: Failed to authenticate to ["10.220.15.254"] as Administrator
Response: Bad HTTP response returned from server (401).
what should be my for windows instance.
You should configure Windows Remote Management in the server as described at http://docs.opscode.com/plugin_knife_windows.html
Your error is due to Basic Authentication not being enabled, you have to run the following command in the Windows machine before attempting the bootstrap:
winrm set winrm/config/service/auth #{Basic="true"}
If running it from PowerShell put the parameter in single quotes '#{Basic="true"}'

Resources