IIS test GET on website link - iis

I have 100 web servers and noticed that some of them have request filtering enabled for ".exe" extension. This means that if a user wants to access a .exe file with an application we ave it is blocked by the server.
Is there a way of doing any type of command line or script whereby I know which servers are affected? Currently I am testing by doing a manual check by going to internet explorer and typing in:
http://***SERVER1***/website/OFFICEPRO/2007/Office%20Professional/setup.exe
http://***SERVER2***/website/OFFICEPRO/2007/Office%20Professional/setup.exe
If I get a pop-up box stating to enter my credentials then that works. Hwoever if I get "Error Page (404)" then that does not work.
Thanks,

You can use powershell to do this, the following should get you on your way:
$webClient = new-object Net.WebClient
gc servers.txt | Foreach-Object {
# send credentials to server
$webClient.UseDefaultCredentials = $true;
$url = "http://$_/website/OFFICEPRO/2007/Office%20Professional/setup.exe"
try
{
$reult = $webClient.DownloadString($url)
Write-host -fore Green $url "OK"
}
catch [System.Net.WebException]
{
Write-host -fore Red $url $_
}
}
The file named servers.txt contains the list of servers you want to check.

Related

Is there a native function for downloading a file in neutralinojs that I can use?

When you right click on a download link in a neutralino app, there is a "download linked file" option which one selects then their file is downloaded.
How can I call that function to download a file in my app.
One method I've been working with (which comes along with its own pitfalls) is using Powershell. The pitfall is that each user may have different versions of Powershell or different environment settings.
This method works on my development computer, but when testing on my laptop as a new user, it fails. But I have very little knowledge of Powershell and I think there is a way to make it work.
My progress so far:
// Create message for Neutralino to execute
let message ='powershell $download = Invoke-WebRequest -UseBasicParsing -Uri "'+insertCleanedURI+'" -OutFile Downloads/'+cleanName+'.fileExtension';
//Next run Neutralino's command execution method
let response = await Neutralino.os.execCommand({
command: message
});
// Capture the response from powershell which Neutralino will receive, and continue with logic
If (response.output.includes("Example Server Response") {
// success, the file has downloaded to the folder & file name specified, do further stuff
} else {
// failed, try to debug the issue
}
Edit: Realized you asked specifically for a native function, not using Powershell. This is how I found you question because I was wondering if I was doing this the hard way.

Empty "Parsed-HTML" field on using "invoke-webrequest" in Azure Powershell Runbook

I am trying to make a rest API call using "invoke-webrequest" in azure powershell runbook.
At first, I got the error message regarding the Internet Explorer Engine. When I searched about it, I found that using **-UseBasicParsing** would solve the problem. However, after using it, I am not facing the error message anymore but I am getting empty "**Parsed-Html**".
The code is running fine when I am running it locally.
$result = invoke-webrequest -uri $url -Headers $Header -UseBasicParsing
I expect the output of Parsed-Html to be an object, but it is null.
In Automation, when we use cmdlet Invoke-WebRequest we need to use the–UseBasicParsing option as we do not have the Internet Explorer in Azure Automation sandboxes.
In this scenario you should use **HtmlAgilityPack**. Upload the **HtmlAgilityPack.dll** as module and use command "add-type -Path .\HtmlAgilityPack.dll " in runbook to generate the **HtmlDocument**
Code would look something like below:
$URI = "https://www.google.fr/search?q=googe&rlz=1C1CHBF_frFR711FR711&oq=googe&aqs=chrome..69i57j69i60l5.912j0j7&sourceid=chrome&ie=UTF-8#q=google"
$wc = New-Object System.Net.WebClient
$htmlString=$wc.DownloadString($URI)
cd C:\Modules\User\HtmlAgilityPack
add-type -Path .\HtmlAgilityPack.dll
$doc = New-Object HtmlAgilityPack.HtmlDocument
$doc.LoadHtml($htmlString)
$root= $doc.DocumentNode
$root.SelectSingleNode("//head/title").Innertext
You can check this link for further reference.
Hope it helps.

SharePoint Quick Launch not opening

I want to edit a link on the left side of a SharePoint 2013 Standard site. Clicking on Edit Links and changing the link to a desired site and then saving shows error "This operation has timed out. Please try again." and clicking on Quick launch keeps spinning. I have full access to the site.
What could be the cause ?
did You consider using PowerShell as a workaround solution? If something in SharePoint that is OOB and does not work I always consider PS to fix something :).
For Your case something like this may do the trick (example to delete and update):
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$SPWeb = Get-SPWeb "[URL]";
$QuickLaunch = $SPWeb.Navigation.QuickLaunch;
foreach($item in $QuickLaunch)
{
$item.Title;
if($item.Title -eq '[quickLunchItemTitleToDelete]')
{
$SPWeb.Navigation.GetNodeById($item.Id).Delete();
}
if($item.Title -eq '[quickLunchItemTitleToModify]')
{
$item.Title = "[NewName]";
$item.Update();
}
}
also I saw You have in site settings link to Quick Lunch. But You may turn on a feature in web to get the more advanced 'Navigation' link and maybe from there You will be able to modify the link You need.
Go to Site settings > Under Site collection admin > Site collection
features
Click Activate in-front of SharePoint Server Publishing
Infrastructure
BUT please be aware that turning on this feature will add also other components to Your which may be not desired.
I hope this will be of any help to You :)

PDF File not opening in browser for sharepoint 2010

Recently we have moved our web application from one server to another in Sharepoint 2010. Back up of entire web application was taken and restored in another server. But in the new server , the PDF files in the document library is not getting opened in browser. it always open in browser
I have already made following changes but didn,t work
Set browser file handling to Permissive from central admin
Set "open in browser" in setting s of doc library
Set the doc library file handling property using
$docLib = $web.lists["Your Document Library Title"]
$docLib.BrowserFileHandling = "Permissive"
$docLib.Update()
Added "AllowedInlineDownloadedMimeType.Add("Application/Pdf") in web app
Installed Adober eader in client machine
Even after trying all these, the PDF files are still opening in Client application(Adobe reader) but not in the browser
It would have been great help if anybody provide a solution for this. I have been banging head on this for two days
Regards
Vishnu
You need to add the MIME type to SharePoint 2010 to enable this - and it needs to be done at Farm level.
The powershell on here will do it; (I've not run it, but it is Technet so source should be good)
# <#
# .DESCRIPTION
#
# This script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property list of defined SharePoint 2010 Web Application.
#
# Script prompts you for MIME type and Web Application URL.
#
# Code shall run in context of Farm Administrators group member.
#
# .NOTES
# File Name : Add_MIME_Type.ps1
# Author : Kamil Jurik, WBI Systems a.s.
# Created : 11/12/2011
#
If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
Get-SPWebApplication
$WebApp = Get-SPWebApplication $(Read-Host "`nEnter Web Application URL")
Write-Host `n"Mime Type Examples:"`n"application/pdf, text/html, text/xml"`n
If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type"))
{
Write-Host -ForegroundColor White `n"Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url
$WebApp.AllowedInlineDownloadedMimeTypes.Add($MimeType)
$WebApp.Update()
Write-Host -ForegroundColor Green `n"The" $MimeType "MIME type has been successfully added."
} Else {
Write-Host -ForegroundColor Red `n"The" $MimeType "MIME type has already been added."
}
You can set the Browse file handling property to permissive
http://technet.microsoft.com/en-us/library/cc262107(v=office.14).aspx

Is it possible to access RSA Secure Id programmatically for use in Test Automation?

I have a requirement where I need to enter secure Id from RSA token during login authentication and then start running automation test.
Is it possible to access the RSA token value programmatically through any api or any other way , so that test flow can be automated completely?
We automated our login to a vpn that uses rsa secure id and Cisco AnyConnect, by doing the following:
1) Open rsa secure id programatically the way you want
2) Run the following .ps1
#Source http://www.lazywinadmin.com/2010/06/powershell-get-clipboard-set-clipboard.html
function Get-ClipBoard {
Add-Type -AssemblyName System.Windows.Forms
$tb = New-Object System.Windows.Forms.TextBox
$tb.Multiline = $true
$tb.Paste()
$tb.Text
}
# end Source http://www.lazywinadmin.com/2010/06/powershell-get-clipboard-set-clipboard.html
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('the name')#Here you need to write the name that appears on the left top corner of the rsa secure id window
Sleep 1
$wshell.SendKeys('{TAB}')
$wshell.SendKeys('~')
$a = Get-ClipBoard
#Source http://www.cze.cz
#This script is tested with "Cisco AnyConnect Secure Mobility Client version 3.0.5080″
#Please change following variables
[string]$CiscoVPNHost = 'the vpn you are trying to connect'
[string]$Login = 'your user'
[string]$Password = $a
#Please check if file exists on following paths
[string]$vpncliAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe'
[string]$vpnuiAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe'
#****************************************************************************
#**** Please do not modify code below unless you know what you are doing ****
#****************************************************************************
Add-Type -AssemblyName System.Windows.Forms -ErrorAction Stop
#Set foreground window function
#This function is called in VPNConnect
Add-Type #'
using System;
using System.Runtime.InteropServices;
public class Win {
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
}
'# -ErrorAction Stop
#quickly start VPN
#This function is called later in the code
Function VPNConnect()
{
Start-Process -FilePath $vpncliAbsolutePath -ArgumentList "connect $CiscoVPNHost"
$counter = 0; $h = 0;
while($counter++ -lt 1000 -and $h -eq 0)
{
sleep -m 10
$h = (Get-Process vpncli).MainWindowHandle
}
#if it takes more than 10 seconds then display message
if($h -eq 0){echo "Could not start VPNUI it takes too long."}
else{[void] [Win]::SetForegroundWindow($h)}
}
#Terminate all vpnui processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpnui")
{$Id = $_.Id; Stop-Process $Id; echo "Process vpnui with id: $Id was stopped"}}
#Terminate all vpncli processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpncli")
{$Id = $_.Id; Stop-Process $Id; echo "Process vpncli with id: $Id was stopped"}}
#Disconnect from VPN
echo "Trying to terminate remaining vpn connections"
start-Process -FilePath $vpncliAbsolutePath -ArgumentList 'disconnect' -wait
#Connect to VPN
echo "Connecting to VPN address '$CiscoVPNHost' as user '$Login'."
VPNConnect
#Write login and password
[System.Windows.Forms.SendKeys]::SendWait("$Login{Enter}")
[System.Windows.Forms.SendKeys]::SendWait("$Password{Enter}")
#Start vpnui
start-Process -FilePath $vpnuiAbsolutePath
#Wait for keydown
#echo "Press any key to continue …"
#try{$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")}catch{}
#Exit
All you need to do now is to set your vpn, and user on the script above.
You need to specify what kind of token you use.
There are number of choices here I heard of:
hardware token
software token application (Mac OS, Windows, iOS, Android, Windows Mobile, and few others)
web browser token
Please check this link for more details:
http://www.emc.com/security/rsa-securid/rsa-securid-software-authenticators.htm#!offerings_for_web_browsers
With hardware token you will need to use some kind of camera and read pixels of the image taken (I will not be able to help you there)
Software token is simpler.
I have recently created small command line tool that is able to execute, enter PIN, and read Passcode generated in the token application.
I cannot send you the tool (property of my company), but I can give you some tips what you need to do to create your own application that will do the same stuff.
But first you need to tell me whether you use software token or not.
OK.
Since you have software token I'll describe what my app do to automatically connect to VPN.
1) you need to have your software token configured prior doing this.
On top of that VPN client will need to be also configured, and connection must be listed on available connection list.
When it is configured you can do your auto VPN Connection.
We have software token similar to this one:
https://ssl.seagate.com/ssl/docs/soft_token_install_instructions.html
Our VPN Client looks looks something like this one:
http://wireless-setup.wsu.edu/msIPSEC.html
2) Once all tools are configured you can start your VPN connection.
You need to be prepared to do deep investigation.
Guys from RSA worked really hard to make it impossible this what we are doing here.
They don't use ordinary controls. They have created their own controls I do not have
spec for.
I have done it using C++ and WIN32 API functions. This is my recipe.
a) read parameters passed to the program
b) validate the parameters
I have number of params like PIN, connection number to establish, Command to run when connection is established etc. They can be hardcoded of course but to be flexible I can pass them from command line.
c) check for token application [EnumWindows]
Token app can have 2 top level windows [The one you enter PIN, and the one with passcode]
If I detect both windows opened I close the app and restart it.
You can try sending Message WM_CLOSE to close the app. I simulate users action to press "X" close button
//restore it <if minimized>
SendMessage(hwndTokenApplicationPinWindow,WM_SYSCOMMAND,SC_RESTORE,NULL);
//close the app
SendMessage(hwndTokenApplicationPinWindow,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(223,14));
SendMessage(hwndTokenApplicationPinWindow, WM_LBUTTONUP,0,MAKELPARAM(223,14));
To start it I use CreateProcess function.
When you restart the app or you had only one window opened, you can now enter PIN.
d) Enter PIN
I simulate users left click on pin window WM_LBUTTONDOWN, WM_LBUTTONUP.
I enter the pin using WM_CHAR.
Once entered, click OK button using WM_LBUTTONDOWN, WM_LBUTTONUP.
Once completed you should have Passcode window displayed.
e) Read passcode
To get the passcode I use Copy button from the token. This button Copy data to clipboard.
We simulate pressing this button: WM_LBUTTONDOWN, WM_LBUTTONUP
And read data from clipboard:
BOOL InvalidData = FALSE;
OpenClipboard(NULL);
HANDLE clip0 = GetClipboardData(CF_UNICODETEXT);
wchar_t* p=(wchar_t*)GlobalLock(clip0);
if(wcslen(p) == MaxPasscodeSize-1)
wcscpy_s(currentPasscode,MaxPasscodeSize,p);
else if(wcslen(p) != MaxPasscodeSize-1 && wcslen(p) != 0)
{
wprintf(L"Error: Passcode in clipboard is invalid\n");
InvalidData = TRUE;
}
GlobalUnlock(clip0);
CloseClipboard();
Now you have Passcode ready to be used in the CISCO VPN Client.
Please let me know if it make any sense to you.
If it does, and you your app works up to this point please let me know and I'll pass instruction to deal with VPN client.
If you need more detailed instruction for the steps above please let me know.
One idea is to record a bunch of clock/token pairs and run the clock back for your program and replay the recording. Actually, if you have the option of cooking the clock, you really only need one pair.
(I did not say it was a GOOD idea.)
Good luck,
/Bob Bryan

Resources