Is it possible to get all IIS sites from WMI? - iis

I'm trying to get all websites from my IIS service, but I need to do it through wmic.
In Powershell, I can do a get-website and the results are in the format below, that is good enough for my needs, but I can't convet it in a wmic command.
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Default Web Site 1 Stopped %SystemDrive%\inetpub\wwwroot http *:80:
my.site 2 Started C:\Users\My/Path https 127.0.0.0:443: sslFlags=0
I searched for some options, but anything helped me. Below is my last tries:
wmic service where name = 'W3svc' call get-website
get - Invalid alias verb.
wmic PATH Win32_ServerFeatrure
2 Web Server (IIS) 0
I can get the service, but I can't call any command.
get-wmiobject -query "select * from Win32_Service where name='W3svc'"
Same problem of second option, I can get the service, but can't get any other info.
Backgroud:
I'm using a Linux client for wmic and I need to connect in Windows Server machines to get info about all websites (active or not) configured in the web server.
Are there any way to achieve it using any wmic command or WQL query?

Related

Using 'msdeploy' to sync a folder on a local IIS server with a remote IIS webserver

I am trying to sync a folder on a local IIS server with a folder on a remote IIS server using msdeploy.exe.
I found some instructions at https://devblogs.microsoft.com/dotnet/web-deploy-msdeploy-how-to-sync-a-folder/ which demonstrated how to do this with the command in the attached image. example msdeploy command to sync folders
My question is what is the 'ComputerName' value referring to? How do I find the 'ComputerName' of the destination server (or any server for that matter).
I tried following the instructions at https://devblogs.microsoft.com/dotnet/web-deploy-msdeploy-how-to-sync-a-folder/ but was not sure how to determine the 'ComputerName' of my destination server.
In the official documentation, there is a detailed description of this parameter, like this:
If you're deploying to the remote agent service on the destination web server, you can specify the target computer name (for example, TESTWEB1 or TESTWEB1.fabrikam.net), or you can specify the remote agent endpoint (for example, http://TESTWEB1/MSDEPLOYAGENTSERVICE). The deployment works the same way in each case. If you're deploying to the Web Deploy Handler on the destination web server, you should specify the service endpoint and include the name of the IIS website as a query string parameter (for example, https://STAGEWEB1:8172/MSDeploy.axd?site=DemoSite).
Can you understand the explanation in this paragraph, or do you not know what remote server you are using?

Setting up intranet web server to send e-mails

All I want to do is have an ability for my intranet web server to send e-mails.
I'm trying to set up the SMTP to listen on port 25 while the websites are on port 80.
I think I might have something that could work (after following a tutorial) but I'm missing a key piece of information. Each site describing how to set up an SMTP server falls short of telling me where I need to go to set up a new e-mail account for this SMTP.
Without it I can't use the powershell lines of code to see if I've set it up correctly (I don't have a "from" to use).
Send-MailMessage
–From ???#[Servers Intranet IP]:25
–To recipient#recipientdomain.com
–Subject “Test Email”
–Body “Test E-mail (body)”
-SmtpServer [Servers Intranet IP]:25
Note I don't know if [Servers Intranet IP]:25 is correct or not but I get a feeling if I can answer how to create the "From" then that piece of information will fall into place. The sites can be accessed internally using [someText].[otherText].net:80 and [Servers Intranet IP]:80
Note: I manage my website using IIS Manager (Version 10.0.14393.0) but the tutorial I followed for creating my SMTP forced me to go use IIS 6.0 Manager. The SMTP virtual server wasn't showing up in IIS Manager (V 10).
Note: In IIS 6.0 Manager, [SMTP Virtual Server #1] has a Domain Name [someText].[otherText].net and Type Local (Default) and it is running.
If this is too obvious, dumb, or makes 0 sense so much so that I deserve a -1 please tell me why and then give me a -1.
More info.
PS C:\Users\[UserName]> Get-Process -Id (Get-NetTCPConnection -LocalPort 25).OwningProcess
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
545 49 16112 27040 0.73 6340 0 inetinfo

sqlcmd not connecting to Azure database

I am trying to use the command below to access my database within Azure
sqlcmd -s tcp:DBNAME HERE.database.windows.net -U USERNAME -P PASSWORD
I get the error
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Named Pipes
Provider: Could not open a connection to SQL Server [2]. . Sqlcmd:
Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout
expired. Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A
network-related or instance-specific error has occurred while
establishing a connection to SQL Server. Server is not found or not
accessible. Check if instance name is correct and if SQL Server is
configured to allow remote connections. For more information see SQL
Server Books Online..
Has anyone ever had this? I have downloaded the latest version of sqlcmd
I need to get a lot of data into my Azure database, but I am running out of options as the Import Data option in management studio cant cope. This was the first method I tried. After processing 70000 of 250000 rows it just goes to stopped with no error message, thats what then led me to try with BCP SQLCMD
Paul
Your command is incorrect. The 'S' should be capitalized and you should provide the server name, not the database name.
sqlcmd -S tcp:myServer.database.windows.net -d database -U username -P password
See the documentation page for the complete syntax of sqlcmd.
Please make a ping to the name of your Azure SQL Database server as shown below:
C:\> ping myserver.database.windows.net
The ping command should fail but it should return the current IP of your SQL Azure Database server. If it fails to return that IP, then you cannot access to Azure server due to a DNS resolution problem.
If the ping command returned the IP address successful, then try to telnet your SQL Azure Database server as shown below.
C:\> telnet myserver.database.windows.net 1433
If the telnet command fails make sure your computer firewall or network hardware is allowing traffic to the IP returned on the previous step and make sure TCP port 1433 is open. If your are trying this from a corporate network, please contact your network administrator with this requirements.
Please note that you may need to enable the telnet command via Control Panel -> Program and Features -> Turn on/off features.
I just want to point out that BCP and sqlcmd are two different tools.
BCP is the bulk copy command. The later is the command line tool for querying.
If you are getting a named pipes issue, you might not have the client and/or server libraries configured.
Please go to SQL Server Configuration manager to check the settings.
By default, Azure SQL database is using TCP and you do not need to tell it on the command line.
In the image above, I am connecting to a Azure SQL database using the correct switches from books on line. Querying the sys.tables catalog returns the information that I expect. Two tables with different names. One duplicated named table under different schemas.
The BCP command will work the same way. You might even want to try a format file.
I want to clarify your statement that importing is taking a long time. Please remember that Azure SQL database is platform as a service. The database tiers are set at predetermined DTU's. That means stuffing the server with a lot of data will result in a throttled server at MAX DTU's.
I would look at the portal and see if that is your situation.
In short, sqlcmd, bcp and the import/export wizard are perfect tools for data loads a lot larger than the numbers you are talking about. Just remember, syntax is key to any successful program!

CUPS session setup failed with 'nt_status_logon_failure'

I am running the CUPS in Linux Debian machine. Using the CUPS I am sending the print request to Windows XP machine. I have enabled the 445 and 139 port and I am able to connect the Windows Machine. Printer is connected to the Windows Machine.
I am sending the print request using the following command
lp -E -d < Printer Name > file name.
After sending I am checking the printer status using the following command
lpstat -p < Printer Name >
I am getting the below error message when I execute the above message.
unable to connect to cifs host will retry in 60 seconds..
When I checked in the log I am getting the below error message.
session setup failed: NT_STATUS_LOGON_FAILURE and NT_STATUS_BAD_NETWORK_NAME
The DeviceURI is like below in /etc/cups/printers.conf
smb://username:password#IP Address of windows Machine/printer_Name
Please let me know if the password is having '#' symbol, how can we specify the '#' with actual syntax in DeviceURI ( user:password#IP )
Unfortunately you provide not enough detailed info about your specific setup. So I will make an effort to take several potential problems into account and give hints how to overcome them:
I.
Did you use the correct share name for your shared Windows printer?
To find out, use this command:
$ smbtree -U windowsusername
You might see something like the following output:
WORKGROUP
\\MURUGA-PC
\\MURUGA-PC\G
\\MURUGA-PC\Z
\\MURUGA-PC\Public
\\MURUGA-PC\print$ Printer Drivers
\\MURUGA-PC\EPSON Stylus CX8400 Series EPSON Stylus CX8400 Series
In other words: your printer's share name may contain spaces. But you cannot use spaces in the device URI for CUPS! What now?
Easy: (1) Either rename the share name on the Windows side. (2) Or escape the space by using %20 instead:
smb://muruga:mysecretpassword#muruga-pc/EPSON%20Stylus%20CX8400%20Serie
II.
Is your Windows XP by any chance using Kerberos authentication? For example, because it is part of an Active Directory environment? Then you should refer to this document on cups.org:
Configuring CUPS to Use Kerberos
Kerberos authentication does not work with username/password, it uses 'tickets'.
III.
Otherwise, if your Windows XP machine is part of a "standard" domain, you may be more successful by ditching your device URI of smb://username:password#ip-address-of-windows/printer_name and use this instead:
smb://username:password#domain_name/windows_host/printer_Name
The username you use has to be the Windows user name (with his/her password) who installed the printer on Windows!
IV.
Alternatively, you may have success by using IPP to print to Windows (though XP needs an IPP-enabling extension installed, provided by Microsoft). Be aware that MS is using a non-standard syntax for their device URIs (using port 80 or 443), and their version of IPP is still 1.0 (which always remained in "draft" status and never made it into an official release by the IETF):
DeviceURI https://mywindowsprintserver/printers/printername/.printer
or
DeviceURI http://mywindowsprintserver/printers/printername/.printer
For username/password authentication to this printer, you need
AuthInfoRequired username,password in /etc/cups/printers.conf and
DefaultAuthType Basic in cupsd.conf.
To use Kerberos, you need
AuthInfoRequired Negotiate in /etc/cups/printers.conf and
DefaultAuthType Negotiate in cupsd.conf.
If the whole setup is in a household with a private LAN/WLAN, you may want to consider removing all access controls (first on the Windows print server side, then):
AuthInfoRequired None in /etc/cups/printers.conf and
DefaultAuthType None in cupsd.conf.
If your problem is that your password contains a '#'-character, then try this:
smb://username:'p#ssword'#domain_name/windows_host/printer_Name
or
smb://username:p%40ssword#domain_name/windows_host/printer_Name

equivalent command of net group /domain for linux?

I've been searching for quite a while for this, And couldn't find it anywhere.
Firstly, Is there equivalent command to:
wmic computersystem get domain
Which return the current user primary domain.
And I've been wondering whether there's an equivalent command of:
net group /domain
A command that returns all the global groups of user current domain.
So far I've been trying to search in different network files at /etc/, Currently the only relevant file I've found was reslov.conf which hold all the DNS, And it might contain more information than i actually need. [Which means that i'll have to query each domain there and 'ask' whether the user is associated with that domain] is there a way which is more efficient than that?
Thanks.
Un*x hostname
hostname -f
host.domain
host host.domain
host.domain has address 192.168.1.35
See man host, man dig and man hostname. Have also a look at See also sections in man pages.
Windows net command under Linux
You have to install at least samba-client package. After installing samba suite, you will be able to run linux's net command:
net help
Usage:
net rpc Run functions using RPC transport
net rap Run functions using RAP transport
net ads Run functions using ADS transport
net file Functions on remote opened files
net share Functions on shares
net session Manage sessions
net server List servers in workgroup
net domain List domains/workgroups on network
net printq Modify printer queue
net user Manage users
net group Manage groups
net groupmap Manage group mappings
net sam Functions on the SAM database
net validate Validate username and password
net groupmember Modify group memberships
net admin Execute remote command on a remote OS/2 server
net service List/modify running services
net password Change user password on target server
...
net help Print usage information
Valid targets: choose one (none defaults to localhost)
-S or --server=<server> server name
-I or --ipaddress=<ipaddr> address of target server
-w or --workgroup=<wg> target workgroup or domain
Valid miscellaneous options are:
-p or --port=<port> connection port on target
-W or --myworkgroup=<wg> client workgroup
-d or --debuglevel=<level> debug level (0-10)
...
The concept of domain you mention is ambiguous.
The equivalent of wmic computersystem get domain is dnsdomainname .
This isn't the command to return the current user primary domain (Active Directory domain or otherwise).
That command for Active directory domain for a given Unix user mapped with samba is
wbinfo --sid-to-fullname `wbinfo --uid-to-sid username` | awk -F "\\" '{print $1}'.
Also see the following related StackOverFlow question.
The equivalent of net group /domain is net ads group -w <domainname>, which is provided by Samba. The net group /domain isn't for a current user as you have described it, if you want the command equivalent of your description you will need to add -U <username> to the equivalent given.
If you are just looking for a command to get the groups of the current user, then getent group | grep username for the unix groups and existing Windows groups to Unix groups as per the Winbind configuration, or
wbinfo --user-domgroups `wbinfo --uid-to-sid username`
for the global groups of a current user in a domain.

Resources