Powershell script to get IIS configuration details - powershell

I am looking for fairly generic powerhell cdm allowing me to get the information about IIS - which directory is the log being written to and which fields it is logging.
I need to query circa 400 servers in the environment and check for the differences
We use 2008 r2 with IIS 7
Thanks a lot in advance

Yeah I know IIS has WMI interfaces which are pretty solid. You'll need to look up the classes though.

Related

Will a PowerShell script developed for a Windows 7 run on Win Server 2008 R2?

I have developed a large PowerShell script that has been refined on a Windows 7 64bit box and now I intend to run it on a Windows server 2008 r2. Assuming the PowerShell versions are the same, will there be any major issues with syntax in-between Win 7 and WS 2008 R2?
The script checks a lot of WMI and registry keys like GWmi Win32_NetworkLoginProfile and Get-Itemproperty -Path Registry::HKLM\Software\Microsoft\"Windows NT"\CurrentVersion\winlogon\
Most PowerShell information is driven towards managing servers so I assume I will be safe, but I want to see if you all can help me learn some lessons before I start banging my head against the wall.
Thanks
There are no syntax differences between PowerShell on Windows 7 and PowerShell on Windows Server 2008 R2. You may encounter differences in existing services, WMI classes, and registry keys, though.
First you should test it on a virtual machine to see if it works or not. Then try it on the physical machine. If it doesn't work, modify the code to the specific registry keys.
The short answer is yes. I run PSv4 on both my desktop and one of my servers running 08. Be sure to import the correct modules (if any) and allow for RPC in your firewall (And winrm) if applicable. One note- depending on what you run with the server, commands and functions are only as good as the version you run against (even when invoked). I ran into this problem as I scripted in v4 and environmentally my firm is almost all v2. Enabled -verbose error output and test in virtual machines or a loner laptop. (This is what I did). Good luck!

PowerShell v2 Server 2003 - Cannot Find Path - Path definitely exists

Usually I can find an answer to PowerShell questions by researching forums and adapting. However, after searching high and low, I cannot find an answer.
I am logged in as a domain administrator working on two enterprise servers in a test domain. $Server2003 is Windows 2003 server running PS v2. $Server2008 is Windows 2008 R2.
Problem: When I am working from $Server2003 I cannot use any commands to access or verify information on $Server2008. This error happens regardless of who the administrator is.
I have used PowerShell fairly extensively in our environments and haven't run into this error before. The error is not present when running commands from $Server2008 on $Server2003. In addition the error is not present when running commands from a production domain. I can also ping the 2003 or 2008 server regardless of which machine I am logged in as.
Examples:
From $Server2008: ping $Server2003 - returns pings
From $Server2003: ping $Server2008 - returns pings
From $Server2003: test-path \\$Server2008\D$\ - Get-ChildItem : Cannot find path '\\$Server2008\D$\' because it does not exist
From $Server2008: test-path \\$Server2003\D$\ - True
The commands I want to run are a lot more complex than test-path; however, if I cannot get the simple command to work I doubt I'll have much luck with a complex one.
The two servers have the same domain, are in the same forest, and have the same domain controllers.
Any ideas where to start?
EDIT: Wanted to add that I have tried using test path from Server2003 to a different 2008 server located in our dev environment (same domain) and it runs the test-path and commands successfully.
can you access the 2008 server remotely by other means? Like the Services MMC? Also, what if you create a share on 2008 rather than rely on the admin share?
The cannot find path error means that it doesn't exist or you don't have permissions. Does it work from a dos prompt?
UPDATE
I just noticed that you used single quotes, the variable will not expand. Enclose it in double wotes and try again

Powershell: Find out if NUMA is configured and how many CPUs are assigned to each NUMA node?

Using Powershell, how can I find out if my server has NUMA enabled and how many CPUs are assigned to each NUMA node?
Update:
I found out here that the microsoft.sqlserver.management.smo.server object object has an affinityinfo field. However, that field doesn't exist in my server object in Powershell when I create it (SQL Server 2005 on Windows XP).
Update:
It appears that the affinityinfo field only exists in SQL Server 2008 R2 and later.
There are APIs available that will get you this information but they are unmanaged which means they are not easily callable from PowerShell (.NET). In order to call these directly you have to use the Add-Type cmdlet to compile C# code into an in-memory assembly which you would then instantiate or invoke a static method from. I have an example of what this looks like on my blog.
Writing the C# is the tricky part because there is a lot of unfriendly looking code associated with it, check out this example. If you are familiar with C#, you might be able to adapt this to what you want. If not Mark has a tool called Coreinfo that looks like it will get you the information you are looking for. It actually calls the same unmangaged API that the linked p/invoke code does (GetLogicalProcessorInformation). You can just call this from PowerShell and process its STDOUT.
I don't think that native OS APIs in Windows 7 and Windows Server 2008 R2 for working with more than 64 logical processors are available in .NET, you can have a look to .NET Support for More Than 64 Processors. This guy use to write a .NET wrapper for OS APIs, you perhaps use that in PowerShell.

Connect to JMX using PowerShell

I am not a developer so please keep that in mind when reading the following message:
I need to be able to use Windows PowerShell to connect to a JMX RMI agent on a host, is this even possible ?
The example string from the java client I have been given is as below:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:7979/jmxrmi");
The reason for this is that I am doing other work in my PowerShell script and would like to keep it all in one place.
Thanks !
This is an unusual mix of two technologies, but it is possible.
On the off-chance that you are attempting to connect to a JBoss server, the quickest way may be for you to call twiddle, a command tool that will dispatch JMX requests to the target JBoss server and return the results to standard out.
Another way is to implement the Jolokia agent on the target servers. This will allow you to issue JMX requests using REST. Responses will also be returned in REST format which you can process in PowerShell using one of these solutions.
Thirdly, you can also deploy the JMX-WS service on your target servers which will allow you to communicate with the JMX server using web-services. This document provides some VBScript examples of this.
None of the above actually uses the JMXServiceURL syntax you outlined, and I cannot think of a way you could actually cleanly integrate this RMI based protocol into PowerShell, but hopefully one of the above will work for you.
========== UPDATE ==========
There may be a way to use the RMI implementation. Take a look at IKVM. It is a Java Byte Code to .NET compiler. I have successfully compiled JMX/RMI java code into a .Net assembly and used it from C#. I think PowerShell will do the same thing.

SSRS 2008 config for SharePoint 2010 integration - Permissions question

I have SharePoint 2010 and SQL server 2008 setup on two machines. I have SharePoint using SQL server for all SP databases. I am trying to get reporting services integration to work, but there seems to be some permissions issue with the SSRS service. From what I understand, it should be possible to navigate to http://server-name/ReportServer and get a simple page showing the server path and the SQL Server version number. This page is only available to windows users with accounts on the local machine.
Both of my machines are on the same domain with "domain level" service accounts. This used to be covered under IIS, but SSRS 2008 no longer uses IIS -- so im unsure how to research it. Ive tried folder permissions for "C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services" with no luck - Im not sure which .config file is the right one either.
Any pointers would be greatly appreciated! Thanks!
This page is nice:
http://msdn.microsoft.com/en-us/library/bb522743.aspx
Have you gone through the SSRS config tool? You should step through each tab and make sure it is configured.
Errors can be found in the instance directory as well.
What error are you getting?