How to get the first element in the collection with appcmd.exe? - iis

I need to get recycling time for the app pool.
I can't use the powershell, so I use appcmd.exe for this. I found that there is a command for this:
%windir%\System32\inetsrv\appcmd.exe LIST APPPOOL test /text:recycling.periodicRestart.schedule.[value='08:23:00'].value
But the problem that I need to specify the time to receive that time:
So now it works as a check if recycling has been scheduled for that specific time.
I suppose appcmd works with this data as a collection. Is there any way to get the first item?

Below command will show you the IIS application pool config setting:
APPCMD LIST APPPOOL "sample1" /config
or
%systemroot%\system32\inetsrv\APPCMD list apppool "sample1" /text:*

Related

Sentinel configuration with NLog/log4net

I have just started to use logging for my C# application. I am using NLog for logging entries to a *.log file and I view it using a Notepad++.
I want to try Sentinel, although I can view the logs on sentinel, I am not sure with the initial steps of sentinel, do I have to do the following every time I want to start sentinel to read a log?
Add new logger
Provider registration - NLog viewer
Visualizing the log
Cant I just start the sentinel and choose from a set configuration files ? If I am running two C# applications one using Log4Net and another Nlog, do I have to go through these over again instead of just selecting a config file?
Also what is the purpose of saving a session in sentinel ?
Once you have a session saved in a file - file.sntl - you can instruct Sentinel to pull that session in on startup by supplying the filename on the command line. I have nlog.sntl saved and use the following from a command script:
#echo off
start /B c:\apps\sentinel\sentinel nlog.sntl
I'm sure you'd be able to create a program shortcut with the same information - I just can't be bothered

can we change an application's connection settings such as data source and initial catalogue using appcmd command

I have a .Net web application whose connection string i am trying to change using command line tool appcmd (available in C:\Windows\System32\inetsrv).
Is it feasible coz i am not able to do it after trying multiple attempts.
No direct reference is available for this but i am trying to use below mentioned query in terms of connection string.
appcmd set config /section:applicationPools /[name=’MyAppPool’].processModel.identityType:SpecificUser /[name=’MyAppPool’].processModel.userName:MyDomain\MyAccount /[name=’MyAppPool’].processModel.password:MyAccountPassword
so my query would become
appcmd set config /section:connectionStrings /[name=’ConnectionStringName’].password:test
but its not working. I am trying to change few more entries in connection string but not able to change even one.
As a work-around, i am deleting the existing connection string and adding a new one with same one and settings i need. But there must be a simpler way to do this.
Can anybody help in resolution?
I will really appreciate that.
I found the answer after some googling. Below is the required connection string I was looking for
C:\Windows\System32\inetsrv\appcmd.exe set config "Default Web Site" /section:connectionStrings /+"[name='TestString', connectionString='Data Source=TestDBServer\SQLEXPRESS; Initial Catalog=TestCatalog;User Id=sa;password=test', providerName='System.Data.SqlClient']"
Please note the + sign before 'name'. It's assuming that no connection string is available with this name. If it does, remove it first and then perform the above step.
Hope it helps.

How are Applications Removed from the IIS Application Pool?

We've got a new server, and I am trying to set it up for our website.
I got a new application for the engineers set up in the Application Pools called eng_app, then added our applications to it.
Now, we have been given an external drive that these applications need to be on, but I can't seem to edit or delete the existing applications.
I tried following the Microsoft Technet Article • Remove an Application (IIS 7) but, as you can see in the screenshot, those are incorrect.
C:\Windows\System32\inetsrv>appcmd delete app "eng_app/drawing"
ERROR ( message:Cannot find APP object with identifier "eng_app/drawing". )
C:\Windows\System32\inetsrv>appcmd delete app "/eng_app/drawing"
ERROR ( message:Must specify the APP object with identifier or "APP.NAME" parameter. )
Could someone tell me what I missed here?
Using Powershell
Go to folder
cd C:\Windows\system32\inetsrv
List all applications to get the correct APP.NAME
.\appcmd list app
Delete the application using fullname for <APP.NAME>.Ex.: "Default Web Site/The.Application".I mean, you must put it with web site name including the double-quotes.
.\appcmd delete app <APP.NAME>
OK, it looks like you can't do it either through the command line or using the Application Pool interface.
After stopping the webservice, what I did was:
go down to the list of Sites and select my application from the list,
click Basic Settings...
change the Application pool with the Select... button and edit the Physical path
Afterwards, you can restart the webservice.
There might be a better way, but this is how I did it.
appcmd delete app eng_app/drawing

How do you specify the deployIisAppPath to a site root that is not DefaultWebSite?

I have a ASP.NET MVC web application project that I want to deploy to my IIS webserver. The site tree is set up thusly:
SERVERNAME(myDomain\Username)
Application Pools
Sites
Default Web Site
MyProjectSite
bin
Content
...
Views
I am trying to deploy to the MyProject site. See below settings that I am using versus the errors I am returning. I am apparently not specifying my site path correctly, but for the life of me, I can't figure out what it should be.
The following settings stay the same between iterations:
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=False /p:MSDeployPublishMethod=WMSvc /p:AuthType=Basic /p:Username="myUserName" /p:Password="MyPassword" /p:AllowUntrustedCertificate=True
Specify SiteName/ as IISAppPath:
Parameters:
/p:MsDeployServiceUrl="https://serverName:8172/MsDeploy.axd?Site=MyProjectSite" /p:DeployIisAppPath="MyProjectSite/"
Error:
Could not complete an operation with the specified provider ("createApp") when connecting using the Web Management Service - I don't want to create a new site. I want to sync the content that is already there.
Specify IISAppPath as Root (supposing that the sitename in the URL is used)
Parameters:
/p:MsDeployServiceUrl="https://serverName:8172/MsDeploy.axd?Site=MyProjectSite" /p:DeployIisAppPath="/"
Error:
Could not complete an operation with the specified provider ("iisApp") when connecting using the Web Management Service - Looks like it is trying to access the Default WebSite or something (to which I have purposefully NOT given myself rights).
Specify IISAppPath as empty string(supposing that the sitename in the URL is used)
Parameters:
/p:MsDeployServiceUrl="https://serverName:8172/MsDeploy.axd?Site=MyProjectSite" /p:DeployIisAppPath=""
Error:
The "ConcatFullServiceUrlWithSiteName" task was not given a value for the required parameter "SiteAppName" - So it interprets "" as actually a null value thus breaking an attempt to concatenate it.
Specify no site attribute in the URL but SiteName/ as IISAppPath
Parameters:
/p:MsDeployServiceUrl="https://serverName:8172/MsDeploy.axd" /p:DeployIisAppPath="MyProjectSite/"
Error:
Could not complete an operation with the specified provider ("createApp") when connecting using the Web Management Service
Specify no site attribute in URL but SiteName as IISAppPath
Parameters:
/p:MsDeployServiceUrl="https://serverName:8172/MsDeploy.axd" /p:DeployIisAppPath="MyProjectSite"
Error:
Could not complete an operation with the specified provider ("createApp") when connecting using the Web Management Service
Now given that it is running a concatenate on the SiteAppName, it must be combining it with the Site name, yes? What are you supposed to put there to get the site to sync to the root of a site?
Update
In an attempt to figure out the proper path scheme, I have tried to publish using the Visual Studio 2012 Publish dialog. In this case, I am returned an error saying that The request timed out (testing the connection works almost instantly and previewing the changes works but takes a few seconds). I checked the event log, and the tracelog for wmsvc to no avail. Even with trace set to verbose, nothing shows up in the tracelog. I have tried disabling the firewalls on both computers, and nothing seems to work on that front either.
Figured this one out.
The problem stemmed from two settings in the Web Deploy page of the project properties. I had previously set this project up (in the Debug configuration) to copy only the files necessary to run the application, and NOT build a zip package. I neglected however to do anything to those settings for the release configuration.
The reason (confidence level 75%) it was trying to use createApp was because it was deploying from the Zip package it had created. So my IISAppPath settings in those cases were fine, I was just deploying the wrong thing.
I set the Create deployment package as a zip file setting to false, and the Items to deploy dropdown to Only files needed to run this application and everything went off without a hitch.
Incidentally I found out (as referred above) that you can use the Publish Profiles outputted by the Web Publish dialog in Visual Studio (2012 only unfortunately; 2010 you have to do some massaging that I am unsure of). I named mine with no spaces, and supplied the password as an argument as well as the Untrusted Certificate setting. Now MSBuild Arguments in the build definition for TFS look like this:
/p:DeployOnBuild=True;PublishProfile=NameOfPublishProfile /p:AllowUntrustedCertificate=True /p:Password=PleaseVerifyMe

NetworkService under IIS has empty AppData path

Using IIS 8 on Windows 8, I've set up an application pool which runs with an identity of Network Service.
In the code for a page, I make calls to:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Both calls return null.
I've tried combinations <identity impersonate="true|false"/> as well as setting the Load User Profile setting to true|false in the application pool setting, but I always get a null result.
I would expect to get one of:
C:\Windows\ServiceProfiles\NetworkService\AppData\Local
C:\Windows\System32\config\systemprofile\AppData\Local
On another user's machine, they get the second folder as the path (IIS 7.5) even though the application pool runs as Network Service.
What could be happening with these profile folders?
In your %WINDIR%\System32\inetsrv\config\applicationHost.config look for <applicationPoolDefaults>. Under <processModel>, make sure you don't have setProfileEnvironment="false". If you do, set it to true.
I think you need the LoadUserProfile setting as well as one additional call from a console:
cd "%~dp0"
md appdata
This would create the required folder for the app pool user. I'm not sure if this will result in Environment.SpecialFolder.ApplicationData returning a correct path though.

Resources