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

Powershell script to export IIS website details

$
0
0
<div class="post-text" itemprop="text">

Hi,

I need to extract all the website details created in our IIS server with the following details. As we have more than 80 sites created in our IIS server, I am searching for an easier way to export these details.

details required :

  • Website Name
  • Bindings
  • State
  • DB Server name [mapped in connection string]
  • DB Name [mapped in connection string]

I am able to extract all the details except DB related available in connection strings using get-website cmdlet. Requesting your help if you know any better way to extract all the information under single file.

Thanks,

Raghavendra.

</div>

Get all virtual sites with redirects

$
0
0

Hello everyone.  Is there a PS script that can run through all 370 virtual sites and list me those that have redirects and what they are?

Powershell to change FTP log direcotry

$
0
0

I am trying to use powershell to modify the FTP log path directory.
I have been able to modify the IIS logs directory. but, no luck changing the FTP logs.

Windows 2012 server with IIS and FTP installed.

Please help ?


lee

Is WebAdministration module for X64 bit programs only

$
0
0

Hi All,

Can someone tell me if  the WebAdministration module is x64 bit compatible only. I have a windows 2008R2 server OS and the windows features etc installed. I can execute command and navigate the IIS tree using the powershell x64 version. But the X86 powershell ISE does not work well with IIS at all. I get the following error.

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:1 char:1

I have seen this error reported in many forums, but there isn't a direct answer to this question. if the module is x64 compatible only then why is it not marked x64. I have a very high opinion and expectation of Microsoft with all they do. I suspect my capability rather than think that microsoft would have made a mistake not calssifying the module architecture to be just x64 compatible. If there is a way for the webadministration to work in powershell ISE x86, that would be really helpful. anywork around also would help rather than change a whole lot of code to run using Invoke-Command. Please let us know.

I would also like to share that i could import the module in powershell x86 shell. the systems lets me do that since it is not classified as x64 only. before importing i do not see the IIS drive and after i do see the IIS. i can switch to it. but that is it. any other command to get-childitem, cd to Site etc throws me off.

Thanks,

Jealani Shaik

Using Powershell how to Revert-to-Parent in handler mappings for an application in IIS

$
0
0

I want to modify the IIS Web application Handler mappings to Revert to Parent. I did this manually like below.

Open IIS , Site/Web application, Clicked Handler Mappings, in Actions Clicked "Revert to Parent".

I want to automate this using PowerShell. Can someone help?

I have already tried below :-

1) Clear-WebConfiguration -pspath 'IIS:/sites/Default Web Site/MyWebService' -filter 'system.webServer/handlers'

2) Clear-WebConfiguration -Filter /System.WebServer/Handlers -PSPath 'IIS:/sites/Default Web Site/MyWebService' -force

3) Set-WebConfiguration -Filter /System.WebServer/Handlers -Value @{Name='CGI-exe'; EntryType='Inherited'; AccessPolicy="Read, Script"} -PSPath "IIS:/sites/Default Web Site/MyWebService"

4) Set-WebConfiguration "/system.webServer/handlers/@AccessPolicy/add[@name='CGI-exe']" -Value "Read, Script" -PSPath "IIS:/sites/Default Web Site/MyWebService"

Set-WebConfiguration "/system.webServer/handlers/add[@name='CGI-exe']/@requireAccess" -Value "Execute" -PSPath "IIS:/sites/Default Web Site/MyWebService"

But none suffices my need to "Revert to Parent"

Read Windows Authentication in IIS using Power Shell

$
0
0

Hi,

I need to read whether windows authentication is enabled or disabled using Power Shell scrript, I tried below but doesn't show appropriate information:

Get-WebConfiguration system.webServer/security/authentication/windowsAuthentication/* 'IIS:\sites\Default Web Site' -Recurse | format-list

Microsoft Dynamic CRM Deployment Manager - Set Binding Type Using Script

$
0
0

Hi Guys, 

I want to ask, is it possible set Binding Type as Https using powershell script ?

And if it possible , can I change also portname for Web Application Server, Organization Web Service, Discovery Web Service and Deployment Web Service on it?

I knew it well how to configure it from UI. 

Unable to change Management Services certificate via PowerShell

$
0
0

I've used the following script to successfully change from the default web management certificate to a certificate generated from our internal CA's, but now I am no longer able to do so. All the steps in the script run without error, however the old certificate is still shown in the IIS Manager (even closing/reopening console shows the same). I've confirmed that I get my correct certificate from the store (correct friendlyname/thumbprint).

Has anyone else had issues changing the management services certificate via PowerShell on Windows 2012 R2? Wondering if something might have changed with a windows update. I can successfully change the certificate through the UI without issue.

We recently upgraded our CA's, and I need to change a lot of servers, and need to be able to do this via PowerShell if possible.

Thanks,

Jerame

#Enable IIS Remoting
Set-ItemProperty -path HKLM:\Software\Microsoft\WebManagement\Server -name EnableRemoteManagement -value 00000001
Set-Service WMSvc -StartupType Automatic

#Get Web Server Certificate for Web Management
Set-Location -Path Cert:\LocalMachine\My
Get-Certificate -Template WebServer -Url ldap:
$IISCert = Get-ChildItem -Path Cert:\LocalMachine\My | Where {$_.Subject -like "*CN=$env:computername*"}
$IISCert.FriendlyName = "WebMgmt"

#Set IIS Administration to use real cert
Import-Module WebAdministration
#Remove default certificate
Remove-Item -Path IIS:\SslBindings\0.0.0.0!8172
#Add real web server certificate
$IISCert = Get-ChildItem -Path Cert:\LocalMachine\My | Where {$_.FriendlyName -eq "WebMgmt"} | Select-Object -ExpandProperty Thumbprint
Get-Item -Path cert:\localmachine\My\$IISCert | New-Item -Path IIS:\SslBindings\0.0.0.0!8172
Start-Service WMSvc


Edit the Directory physical path Location for Applications Under Default Website

$
0
0

Hi,

I'm currently looking for a way to amend applications physical paths through power-shell instead of manually going into every application.

I have a number of applications under the default website which have applications under them that need to be changed. 

Is there a way of changing them through power-shell , so that I can possibility eventually run the powershell through SQL. 

Help will be appreciated 

Configure Virtual SMTP with Powershell

$
0
0

Hello All,

I am very new to this powershell scripting thing. I have been googling around and couldn't find a solution. I need to configure a couple of things.

1. Change the domain name configure for virtual smtp. It was set to Computer Name by default.

2. Change the outbound security and add a basic auth to it.

Can someone please help me on this.

Regards

Niraj

Need to migrate all the FTP Data in Default FTP site to Remote server (Default FTP Site)

$
0
0

Hi Guys,

Need to migrate all the FTP Data in Default FTP site to Remote server (Default FTP Site).

Can anyone help me in getting this " Migrating or retrieving all the FTP data in Default FTP site to Remote server(Default FTP site)

either through Powershell script

Changing the Identity for App Pools through PowerShell

$
0
0

Hi, 

      I'm trying to amend/ add the identity of the application pool through power shell, i need to pass through the username and password ? 

and having some difficulty doing. 

Many thanks

Get-WebRequest - The method or operation is not implemented

$
0
0

When I run this command I get the following error. Is it not ready yet for use?

C:\Windows\system32> Get-WebRequest
Get-WebRequest : The method or operation is not implemented.
At line:1 char:1+ Get-WebRequest+ ~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (:) [Get-WebRequest], NotImplementedException+ FullyQualifiedErrorId : System.NotImplementedException,Microsoft.IIs.PowerShell.Provider.GetWebRequestCommand



Compiling ASP.NET project in PowerShell?

$
0
0

Hello

Is it possible to compile an ASP.NET project (Visual Studio) in PowerShell before uploading that same project to a Web hosting service and, if so, what would be the command line?

In MS-DOS Command Prompt, it is:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler -p "C:\Visual Studio Year\ProjectFolder" -v /-u "C:\CompiledProject"

Thank you.

help with ftp authorization rules

$
0
0

Hi everyone - I've been working on this script that's supposed to be for a simple project but is getting more and more complex.  Bear with me..

I've been tasked with setting up an FTP server on Windows Server 2008R2 within IIS (v7.5), pretty straight-forward.

I also had to configure user-isolation because of a security requirement, no problem there.

The ugly part is, I need to have a few hundred LOCAL accounts created so they can login to the FTP server, which is again, utilizing User Isolation - which means that identically-named folders have to be created under a LocalUser folder where my FTP site resides.  Then those folders have to have NTFS permissions applied to each folder so only the corresponding user account has modify rights.  Lastly, those folders have to mapped as virtual directories inside my ftp site and FTP Authorization rules created for the local accounts we created. 

I've gotten it all done except for the authorization part.  I'm stuck on the last tiny block.

Note: the local paths are correct, and the site name is an fqdn.  Also note Import-Module WebAdministration is called earlier in the script.

$VDirs = Get-ChildItem "F:\FTP\LocalUser"
foreach ($VDir in $VDirs) 
{ Add-WebConfiguration -Filter "/system.ftpServer/security/authorization" -Force -Location IIS:\sites\MYFTPSITE.DOMAIN.COM\LocalUser\$VDir -PSPath IIS:\Sites\MYFTPSITE.DOMAIN.COM\LocalUser\$VDir -Value (@{accessType="Allow";roles="";permissions="Read, Write";users="$VDir"}) }

When I run this script, I get no errors, the authorization block 'appears' to work, but when I go check IIS, it did not create ANY authorization rules for the corresponding folders.

I've tried several iterations of permissions="Read, Write" "Read+Write", "Read,Write"  permissions=3 ,etc.  Nothing works.  I'm also not terribly clear on what the -location attribute does or if it's right?  Someone help me push this thing over the finish line!

Thank you in advance!


DSC alternatives

$
0
0

Hello

currently maintaining DSC for IIS in a somewhat large environment.( production and test servers) right now all developers have to request permission and sites to be setup. it seems to be a lot to maintain. all requests for additional iis features must be done by request and approved etc. on site changes like permissions or to create a virtual folders, after doing the pull and push the change can take 30 minutes for one change.

developers only have the only ability up copy files to their sites' shares.

its nice that all the servers have the same base image but now its maintaining the small stuff is a little much.

looking for ways to improve what DSC is doing or looking for a different solution. thanks

Trying to install IIS PowerShell Snap-in

$
0
0

Hi,

I have been unable to install the IIS Powershell Snap-in for Windows 2008 servers.

I tried following the below after no luck:

Information: For legacy systems with IIS 7.0 (Windows Vista, Windows 2008) PowerShell WebAdministration snapins are not part of IIS.

Resolution: Download and install the PowerShell WebAdministration snapins found at the following link:http://www.iis.net/downloads/microsoft/powershell

If I navigate to https://www.iis.net/downloads/microsoft/powershell and click install this extension I either recieve a Runtime Error page or get redirected tohttps://webgallery.microsoft.com/gallery.

Not really sure what I am doing wrong and it's probably something really obvious but I cannot seem to find it :(

The data is invalid Error using Powershell Remoting and Get-WebSite (WebAdministration Module)

$
0
0
I'm using Win 7 64 bits, Windows PowerShell 2.0, and VS 2010 , .NET 4.0 and Unit Test project. C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe (32 bits) I use PS Console like this: PS C:\Users\user1> (gwmi win32_process | ? { $_.processname -eq "powershell.exe" }) | select commandline commandline ----------- "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" Now, I connect to remote machine, Win2008 R2 64 bits: PS C:\Users\user1> Enter-PSSession 'descasiisw01' -Credential:'desiisw01\instalador' [descasiisw01]: PS C:\Users\instalador\Documents> import-module WebAdministration [descasiisw01]: PS C:\Users\instalador\Documents> Get-WebSite Name ID State Physical Path Bindings ---- -- ----- ------------- -------- Default Web Site 1 Started C:\inetpub\wwwroot http *:80: net.tcp 808:* net.pipe * net.msmq localhost msmq.formatname localhost http *:80:descasiis --- OMITED --- I test using too PowerShell ISE and works fine. Now, I using C# to call PowerShell scripts: var cmdPS = string.Format("-File \"{0}\" {1} {2} {3} {4} {5} ", PSTestRemoteDeploy, DeployEnvironment, server, group, firstServer, lastServer); //cmdPowerShell = Path.Combine(Environment.GetEnvironmentVariable("windir"), @"Syswow64\WindowsPowerShell\V1.0\powershell.exe"); cmdPowerShell = Path.Combine(Environment.GetEnvironmentVariable("windir"), @"system32\WindowsPowerShell\v1.0\powershell.exe"); var argumentsPS = "-ExecutionPolicy Unrestricted "; argumentsPS += "-WindowStyle Hidden -NonInteractive -NoLogo "; var startInfo = new ProcessStartInfo(); startInfo.FileName = cmdPowerShell; startInfo.Arguments = argumentsPS + cmdPS; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; using (var process = new Process()) { process.StartInfo = startInfo; process.Start(); output = process.StandardOutput.ReadToEnd(); errors = process.StandardError.ReadToEnd(); } I have those ps1 files: === testRemote1.ps1 === $serverName = "desiisw01" $username = "desiisw01\installer" $password = "xxx" $adjPwd = $password | ConvertTo-SecureString -asPlainText -Force $testCred = (New-Object System.Management.Automation.PSCredential($username,$adjPwd)) Invoke-Command -credential $testCred -computer $serverName -scriptblock { Import-Module WebAdministration; Get-Website } # The same error for those: # dir "IIS:\Sites" # Get-ChildItem IIS:\Sites # the error "Remoting data is missing errorCategory_Category property. # Get-Website | select name,state,ID,physicalpath,bindings and === testRemote2.ps1 === $serverName = "desiisw01" $username = "desiisw01\installer"$password = "xxx" $adjPwd = $password | ConvertTo-SecureString -asPlainText -Force $testCred = (New-Object System.Management.Automation.PSCredential($username,$adjPwd)) Invoke-Command -credential $testCred -computer $serverName -scriptblock { import-module -Name webadministration foreach ($site in get-website) { write-host $site.physicalpath } foreach ($site in Get-Website) { #PS Values write-host "#PS Values" write-host $site.PSPath write-host $site.PSParentPath write-host $site.PSChildName write-host $site.PSDrive write-host $site.PSProvider write-host $site.PSIsContainer #Attributes write-host "#Attributes" write-host $site.name write-host $site.id write-host $site.serverAutoStart write-host $site.state #Child Elements write-host "#Child Elements" write-host $site.bindings write-host $site.limits write-host $site.logFile write-host $site.traceFailedRequestsLogging write-host $site.applicationDefaults write-host $site.virtualDirectoryDefaults write-host $site.ftpServer #Other write-host "#Other" write-host $site.applicationPool write-host $site.enabledProtocols write-host $site.physicalPath write-host $site.userName write-host $site.password write-host $site.ItemXPath } } I get this error using testRemote1.ps1: The data is invalid. (Exception from HRESULT: 0x8007000D) + CategoryInfo : NotSpecified: (:) [Get-Website], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Micr osoft.IIs.PowerShell.Provider.GetWebsiteCommand and using testRemote2.ps1 doesn't fail. All works fine!!. How can I avoid "The data is invalid" error ? may be any problem using any property of an website ? PD: Before I get error, in another tests, I don't know I cannot get it: Get-Website : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154. En D:\TFS\TestResults\user_machine 2012-05-30 16_15_28\Out\Tests.Script1.ps1: 50 Car cter: 12 + Get-WebSite <<<< + CategoryInfo : NotSpecified: (:) [Get-Website], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Micr osoft.IIs.PowerShell.Provider.GetWebsiteCommand I test using 64-bit PowerShell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 32-bit PowerShell: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe **References** http://learningpcs.blogspot.com.es/2011/08/powershell-x86x64-iis-provider-error.html Can’t use WebAdministration module when using powershell from c# http://lintaonz.wordpress.com/2011/01/19/cant-use-iis-module-when-using-powershell-from-csharp/ http://www.eighty-twenty.net/weblog/article/149/powershell-x86-fail http://www.techblogistech.com/2012/05/errors-with-powershell-webadministration-module/#more-857 http://stackoverflow.com/questions/3501001/windows-powershell-snap-in-for-iis-fails-on-32-bit

“Invalid Class String (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))” when using Invoke-Command Get-Item

$
0
0

I am running the following command on different servers:

Invoke-Command -ComputerName $slave { Import-Module WebAdministration; Get-Item $args[0] } -Args $sitePath

Where `$slave` is the computer name and `$sitePath` is "IIS:\sites\TestWebsite".

This works fine on some servers, whilst on other servers it generates the following error:

Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

Have you got any ideas why this is the case?

I have asked on multiple forums but nobody was able to help and pointed me towards this forum, so you really are my last resort to fix this issue! Please help!

Retrieve User Session count of Web Application

$
0
0

Good Morning,

I posted this question on the TechNet Powershell forums, and it was recommended to post over here.

Is it possible to get a user session count of a web application with Powershell? I know I can get the count at the web site level using this

Get-Counter "\\$ServerName\web service($website)\current connections"

But would like to get this information at the web application level, since the web site hosts many web apps, and each of them can either use the same app pool or one unique to the application.

Viewing all 136 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>