I Have some WCF services hosted in iis. Using powershell script i want to stop and start individual services(or applications).i found so many articles for stop App-pool.but i want a specific application to be stopped.And i have heard that with WMI we can make it.But i could not find any relevant script for that.
In IIS, you can only stop an "Application" by stopping it's associated Application Pool. Thus the necessity to stop a specific application would require you to organize your applications into Application Pools such that you would only stop a single (or group) of applications when stopping a specific Application Pool.
By organizing your Applications into multiple Application Pools, you can thus utilize the app-pool.vbs or Powershell or WMI interfaces to stop the specific AppPool associated with the application you wish to stop.
Related
I'm looking creating some health check scripts via Powershell for my environments. In my health check script I'm including the running status of my IIS Windows Services, and the Worker Process status. However, I can't figure out how to identify if my Appdomain has been unloaded. And if it has, what time was it unloaded.
FYI, the solution at How to check if AppDomain is unloaded? doesn't quite fit the bill. Looking into my own application log is another alternative, but I'm hoping there a way to check that by inspecting the worker process via Powershell or something.
My application is running on Windows Server 2012 R2 and IIS 8.5, and my health check scripts are using Powershell v4.0.
I intend to find out the unused application pools among tens of live app pools on each server in a web farm containing a number of servers. The app pools are isolated per website and application.
I have listed out the application pools per server using a PS script - I'm a newbie btw, however I'm unable to match the IIS logs against the website ID for the corresponding application pool to determine if any traffic is served by the website/application at all.
This is mainly for housekeeping reasons. Is there any better approach I can take to automate the entire process?
One would think this would be easier--perhaps there is an easier way, but the following is what I was able to come up with. I have never used PowerShell to manage IIS so it's likely that someone who has more expertise in the area will have a more concise approach.
import-module WebAdministration
# get a list of the application pools
$pools = dir IIS:\AppPools
# iterate through the pools and find the ones that are not used by any websites
foreach($pool in $pools){
if ((Get-WebConfigurationProperty "/system.applicationHost/sites/site/application[#applicationPool='$($pool.name)']" "machine/webroot/apphost" -name path).Count -eq 0)
{
write-host $pool.name "has no websites."
}
}
I have a C# application that enables users to write a test and execute it (client). It also supports distributed execution over multiple machines using a central server and agents on said machines.
The agent is practically a duplication of the original execution ability but it is in a standalone solution.
We'd like to refactor that because:
Code duplication.
If a user will try to write and execute on a machine that runs an agent, there will be a problematic collision.
I'm considering 2 options:
Move this execution to a service, that both client and agent will use. I mean a service that will run locally, not a web service.
Merge client and agent - we'll have no agent, but the server will communicate with the client as an agent instead.
I have no experience in working with services. Are there any known advantages/disadvantages to either options?
A common library shared by both client and agent sounds more appropriate to allow simple cases such as just using the client and avoid the overhead of having to set up an extra service locally.
I am working on an automated deployment process for a web application. The deployment will need to:
Deploy DB changes to database using sqlpackage.exe
Deploy reporting services reports to the reports server using the web service
Deploy web app to web server(s)
Deploy fonts for reports
among other things
The first two are reasonably straightforward to run from the web server, as the web service and db are contactable, and the tools to deploy run over the network.
From reading it appears that powershell remoting should be the way to go, and internally this would not be a problem. However when deploying to production, this will be being carried out in a datacentre, where the machines (2web, 1db) are not on a domain at all. I'd like to come up with a generic process that can run both internally and externally with the appropriate configuration. Powershell remoting, with machines not in a domain appears to require a fair bit of configuration using https etc., as NT credentials can't be validated.
Should I battle out configuring powershell remoting, or would configuring this to just use psexec to execute a powershell script directly on the remote machien, copying the deployment artifacts to a drop folder on the remote machine be the best way to go?
psexec seems to "just work". It appears powershell remoting comes with a lot more pain.
Why not use psexec then? You can restrict it's role to just getting you on to the remote machine, and not let it infect your scripts. I have not attempted to get ps remoting working on a non-domain, but it general I have found it to be fairly high effort to get going. Psexec, as you say, can often be simpler.
Excuse the peddling, but the open source framework I helped build called PowerUp essentially does all this for your. It uses a model in which the powershell (well psake) scripts can move execution to another machine by calling a specific function. This can either be done with powershell remoting or psexec - you wouldn't need to change the script, it just requires a setting per environment to say which you would like to use.
Check other the sample at https://github.com/AffinityID/PowerUpSamples/tree/master/SimpleWebsite.
Hopefully that shows you enough, but if not let me know and we can go into more detail.
Recently I tried to enumerate the Windows Services on the VM where my Azure web role instance runs using ServiceController.GetServices() - there's a lot of them including Telephony and CloudDrive which I don't need and so having them started is a waste of resources.
Is it possible to have them not started?
Yes, but you'll need a startup task to do this. Here is what you'll do to stop and disable the Telephony service:
sc.exe stop TapiSrv
sc.exe config TapiSrv start= disabled
As you can see I'm not using the display name (Telephony) but I'm using the service name (TapiSrv). If you want to get a list of service names for your system you can simply execute this command (in Azure you can do this via RDP):
sc.exe query
Executing this command will also give you the state of the service (running, ...).
Note: When calling sc.exe config you need to put a space after the equals sign.
Note: Stopping services can take some time, so I suggest you use a background task to stop/disable the services, in order to keep the startup time of your instance to a minimum.