Quantcast
Channel: PowerShell
Viewing all 136 articles
Browse latest View live

PowerShell command: Feature Delegation settings : Delegate an Application Feature as Read/Write

$
0
0

Hi,

Looking for Power shell script or command, which change the value of "Authentication - Anonymous" from 'Read Only' to 'Read/Write' in Feature Delegation.

Thanksin advance.


How to activate "Allow unspecified ISAPI modules" via Powershell

$
0
0

Hi,

I'd like to Allow unspecified ISAPI modules via Powershell

  1. IIS-Manager
  2. ISAPI and CGI Restrictions
  3. Edit Feature Settings...
  4. Set "Allow unspecified ISAPI modules" (NOT "Allow unspecified CGI modules")

I was trying with

set-webconfiguration system.webserver/security/isapiCGIRestriction -value "True"

but then both Options were active and I only want to activate "Allow unspecified ISAPI modules"

Thanks for Help
Tom

removing isapifilter problems

$
0
0

I am trying to remove a no longer used isapifilter with powershell.

Here is what I am doing,  this removes it from the server level but does not remove the one loaded at the web site level. 

Thank You anyone that can guide me.

--------------------------------------

Import-Module WebAdministration

# remove millsecure if it is loaded

$isapiFilterName = 'millsecure'

$iispathFilter = 'iis:\'

cd iis:\

iisreset /stop

if (Get-WebConfigurationProperty -filter //isapifilters -pspath $iispathFilter -name Collection[name="$isapiFilterName"]) {

     Remove-WebConfigurationProperty -filter //isapifilters -pspath $iispathFilter -name Collection[name="$isapiFilterName"] }

 

Powershell script working in ISE but not from my PHP web page

$
0
0

Hello,

I am trying to automate using powershell and I am running into a dead end.  My script runs in powershell ISE but it fails on my PHP web page.  I have 3 components to my solution.

1.  welcome.php - calls the powershell script.

2.  Input.html. - user submits a file name.

3.  IIS.ps1 - powershell script to create IIS directories, and virtual apps.

I am able to run the script fine in powershell ISE but when I call it from my php page it fails.  My php page is simple, see below.

<html>

<body>

<?php $psScriptPath = "c:\\IIS.ps1";?>

<?php $query=shell_exec(powershell -command $psScriptPath);?>

</body>

</html>

The power shell script I am using is listed below.

Set-StrictMode -Version 2.0

$Site="Default Web Site"

Write-Host ""

Write-Host " " -BackgroundColor DarkCyan

Write-Host " IIS Setup Script " -BackgroundColor DarkCyan

Write-Host " Create Virtual Directories " -BackgroundColor DarkCyan

Write-Host " " -BackgroundColor DarkCyan

Write-Host ""

Import-Module WebAdministration -ErrorAction SilentlyContinue

if (dir IIS:\Sites\$Site) {Write-Host "Checking $Site Configuration"}else{

Write-Error "$Site does not exist, exiting"

exit

}

Write-Host ""

# Read Existing Values

#$rootpath = Get-ItemProperty ("IIS:\Sites\$Site") -name physicalPath

$rootpath = "C:\inetpub\wwwroot\datix"

echo $rootpath

$pool = Get-ItemProperty ("IIS:\Sites\$Site") -name applicationPool

# Create New App

$virdir = "NewApp"

if (dir IIS:\Sites\$Site\$virdir -ErrorAction SilentlyContinue)

{

Write-Host "$Site/$virdir/ Virtual Directory is already configured"}

else

{

# Create Physical Path if Not Present

$apppath = Join-Path $rootpath $virdir

$copypath = "c:\copy\*.*"

echo $apppath

if (!(Test-Path $apppath))

{ New-Item -Path $apppath -ItemType Directory

echo $apppath

Copy-Item $copypath $apppath }

Write-Host "$Site/$virdir/ Virtual Directory is NOT configured, creating..."

# Create new IIS Application

New-Item IIS:\Sites\$Site\$virdir -physicalPath "$rootpath\$virdir" -type Application | Out-Null

# Set Application Pool

Set-ItemProperty IIS:\Sites\$Site\$virdir -name applicationPool -value $pool

# Create Images Virtual Directory

New-Item IIS:\Sites\$Site\$virdir\images -physicalPath "$rootpath\images" -type VirtualDirectory

Write-Host "Created $Site/$virdir/ Virtual Directory"

}

Problem in executing get-WebAppPoolState cmdlet

$
0
0

Hi All,

am trying to get the AppPool status of my application using powershell script.

while doing so am getting an exception as below

get-webitemstate : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At line:12 char:11+        If((get-WebAppPoolState -name $appPoolName).Value -eq "Stopped")+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (:) [Get-WebItemState], COMException+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.GetItemStateCommand

i have executed the script in both 32 as well as 64 bit.

am using Powershell version 3.0 and running the script directly from powershell ise

Pls advice

Menu driven Site creation?

$
0
0

So we would like to automate simple site creation as much as possible. I was thinking a simple HTA that would allow someone to fill in some blanks and then press a button to create a site.

Basicaly the HTA would "build" the Powershell command line with variables.

The command line would look like this:

$SN = Site Name

$SP = Port

$SPP = physical Drive

New-Item iis:\Sites\$SN -bindings @{protocol="http";bindingInformation=":$SP:`$SN"} -physicalPath $SPP

I have built an HTA that will do this, but now I am having problems getting it to run in the correct context.

1. I need to run the HTA as an administrator

2. It needs to call Powershell as an administrator

3. I believe it needs to run the commands in the iisconsole.

It's 2 and 3 that I don't know how to do.

If the HTA is not the way to go with this, then can someone suggest some other menu system?

Which is the recommended method to install IIS 8.5 on Windows Server 2012 R2?

$
0
0

Hello, 

Based on what I found here:  

https://peter.hahndorf.eu/blog/WindowsFeatureViaCmd.html

Is there a reason why I would want to use one script installation method over the other?  

Enable-WindowsOptionalFeature vs Add-WindowsFeature vs dism.exe vs pkgmgr.exe??? 

I made the mistake in 2008 when I started using servermanagercmd.exe and it became deprecated the same year.  Ugh.  I don't want to do the same thing again.  I want to stick with one that is expected to stick around for the long haul. 

Thanks!

When using Add-WindowsFeature cmdlet, are parent items needed to install IIS?

$
0
0

Hello, 

In the following command:  

Add-WindowsFeatureWeb-Server,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Http-Errors,Web-Static-Content

I'm wondering if Web-Server, Web-WebServer, & Web-Common-Http items need to be specified?  

Because if you install:  

Add-WindowsFeatureWeb-Default-Doc

Then Web-Server, Web-WebServer, & Web-Common-Http are automatically checked (installed) when installation is complete.  What's the point of cluttering the on-liner with items that are a 'given' when performing the installation?  

Unless there is a specific reason why the parent items need to be specified?  

By the way, I'm performing a new installation of IIS 8.5 on Windows 2012R2 and I am preparing a script that will be our "Standard" build.  

Thanks!


Set up custom domain feature delegation via powershell

$
0
0

We would like to enable custom domain feature delegation for a number of sites.

Is there a way to do it via Powerhell or appcmd?

This does not work:

%windir%\system32\inetsrv\appcmd unlock config "site.name" section:requestFiltering

Thanks.

IIS: Powershell or appcmd command to reset IIS site's handler mapping to the parent

$
0
0

While automating IIS site deployments we are stuck with automating such simple operation as 'revert handlers to the parent' (IIS 7.5).

We found this 

    Set-Location IIS:\sites\$Site
    clear-WebConfiguration -filter /system.webserver/handlers -force

But this does not work when one changes apppool from .net2 to .net4 and tries to revert the handlers.

A lot of resources refer to a c# script but I think it is also outdated.

Thanks.

IIS Virtual Directory Bits Upload

$
0
0

Hello Everyone.

I'm trying to set with a PS script various configurations for many Web Pages in my Windows Server 2008 R2. I have researched of how can I make a new web site in IIS and to create a new virtual directory, but I cant manage to set the "Allow clients to upload files". I have already install all the IIS and Bits features.

This is how I make the web site and virtual directory.

Import-Module WebAdministration
New-Item iis:\Sites\GS_BITS -bindings @{protocol="http";bindingInformation="*:8736:"} -physicalPath "C:\GS_BITS"
New-Item IIS:\Sites\GS_BITS\Uploads -type VirtualDirectory -physicalPath "C:\GS_BITS"

I found too Little information of how can I set the allow clientes to upload files to true:

(Like this)

$root = new-object system.directoryservices.directoryentry("IIS://127.0.0.1/W3SVC/1/Root/folder")$root.EnableBITSUploads()

or

$root = new-object system.directoryservices.directoryentry("IIS://localhost/W3SVC/1/Root/folder")
$root
.EnableBITSUploads()

I tryied to change the nombre of the folder but it doesnt work.

Do you have any idea?

Scan Server.txt file for servers, Find and document IIS, websites, IPs or Host header info

$
0
0

Hi,

First question. I've a requirement to scan list of servers in a text file (servers.txt), find and document the following:

  1. Whether IIS is installed or not
  2. Presence of IIS websites
  3. IP address of websites used
  4. Host Header of websites used
  5. Port # of websites used

Second question. Is there a software tool that can scan range of IPs address to find whether the IP or FQDN URL has website running or not, whether it is pointed directly via DNS or is it going through load balancer and document the results? Looking for this for internal use to document IIS servers, websites etc that may be hosted on Win 2003, 2008, 2008 R2, 2012, 2012 R2.

Thanks

IIS 8.5 install via Add-WindowsFeature cmdlet - some specific items to select and some items with all subfeatures. How do I do this?

$
0
0

Here is what I have so far in my ps1:  

Add-WindowsFeature `
Web-Server,`
Web-WebServer,`
Web-Common-Http,`
Web-App-Dev,`
Web-CGI,`
Web-ISAPI-Ext,`
Web-ISAPI-Filter,`
Web-Health -IncludeAllSubFeature `
Web-Security -IncludeAllSubFeature `
Web-Performance -IncludeAllSubFeature`

But it ends up installing all sub features for Web-Server, not just the sub features of the category I want all features included (instead of individually listing all the sub features of the category).  

Anyone have any ideas on how to accomplish this?  

Thanks!

Migration of the IIS 6.0 to IIS 8.5

$
0
0

Hi All,

I want know the how to migrate the IIS 6.0 sites to IIS 8.5 via powershell script.

also configure the a particular account for the customer in Application pool any body help us.

Enabling ASP.NET Impersonation on IIS 7.5 website

$
0
0

IIS 7.5 on Windows 2008 R2 on a test system

I am working through the steps to configure a new application in our test environment and have all the Powershell commands to configure except for how to enable ASP.NET Impersonation on this website.

I have run the below command, and it runs without any error. But when I check Authentication settings for the site in the console, it still shows as disabled. I have done an iisreset and rebooted but have seen no change.

Set-WebConfigurationProperty -filter system.web/identity -name impersonate -value $true -location $MySite

I haven't had issues configuring the other authentication methods, just this one. What am I missing?


How to verify if a specific apppool is stopped using appcmd

$
0
0

I am using this command to check for apppools that are stopped.  The problem is that I need to check a specific pool with a specific state.  I can check the name but I cannot check for a state of stopped.  Is there a way to do that using appcmd?

function Check-AppPool {
    param(
        $PoolName
    )
   
$appcmd = "C:\Windows\system32\inetsrv\appcmd.exe"
  & $appcmd list apppool /state:Stopped /xml

$result1 = $LASTEXITCODE
if ($result1 -eq 0)
{
  exit 0
}
else
{
  exit 1
} }
Check-AppPool "DefaultAppPool"

Check State's of application pools

$
0
0

Hello,

I'm try to create a powershell script for monitoring status of all application pools on my server.

what I'll like to do is have a script which does the following:

Timestamp  Apppoolname   State

Currently I can get one of these at a time

Can you help me ?

HTTP Redirect

$
0
0

Can anyone show me how do I set the (Redirect Behavior) to "Only redirect requests to content in this directory (not subdirectories) with powershell; here is the command that I am using 

Set-WebConfiguration system.webServer/httpRedirect "IIS:\sites\$siteName" -Value @{enabled="true";destination="$redirectPage";exactDestination="true";httpResponseStatus="Found"}

Thanks

managedPipeLineMode issue on IIS8.5

$
0
0

Hi Guys,

Basically our organization decided to migrate from IIS7 to IIS8.5 (Win 2012r2). I am using a custom windows powershell script.

The issue is that, First: Identity wasn't tack it by my script ( I did some hard coding for this part and works at the end). Second issue, when I am using managedPipeLineMode  ( Integrated-0, Classic: 1  ) in my script, technically it gets the number; however, it's not actually change it in AppPool to Classic mode and keep it Integrated Mode.

Part of my script


$settings.AppPools.AppPool | foreach {
$poolname=$_.name
$identityType=$_.identityType
$managedPipeLineMode=$_.managedPipeLineMode
$fidId=$_.fidId
$Enable32Bit=$_.Enable32Bit
$dailyRecycle=$_.dailyRecycle

if(!(Test-Path IIS:\AppPools\$poolname))
{
Write-Host "Create Wep App Pool '$poolname' ..."
New-WebAppPool $poolname
Set-ItemProperty ("IIS:\AppPools\"+$poolname) -Name ManagedRuntimeVersion -Value v4.0
Set-ItemProperty ("IIS:\AppPools\"+$poolname) -Name ManagedPipeLineMode -Value $managedPipeLineMode
#Write-Output $managedPipeLineMode
Set-ItemProperty ("IIS:\AppPools\"+$poolname) -Name processModel.IdentityType -Value $identityType
If ($Enable32Bit -ne $null) { # Some Services call 32 bit Oracle app
If ($Enable32Bit.ToUpper() -eq "Y") {
Set-ItemProperty ("IIS:\AppPools\"+$poolname) -name "enable32BitAppOnWin64" -Value "true"
}

Anybody has any idea? 

Cheers,

Arash

ManagedPipeLineMode doesn't changed via set-itemproperty command in IIS 8.5

$
0
0

HI All,

Does anyone have the same issue as me or this is a BUG of IIS 8.5 ?

PS IIS:\> Set-ItemProperty IIS:\AppPools\LTWC02-eCareBellCa -Name ManagedPipeLineMode -Value 1

Powershell actually say nothing after run the above command. However, when you check it in  IIS GUI, ManagePiplineMode still in previous state ( by default in Integrated) 

I really appreciate if anybody has an idea to fix this issue.

Cheers,

Arash

Viewing all 136 articles
Browse latest View live