c:> mklink /d c:\some\directory \\some_server\some_share
This will create a folder named c:\some\directory which will show the content of the share \\some_server\some_share.
This will work also with a remote disk with i.e. \\some_server\C$.
L | M | M | G | V | S | D |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
c:> mklink /d c:\some\directory \\some_server\some_share
This will create a folder named c:\some\directory which will show the content of the share \\some_server\some_share.
This will work also with a remote disk with i.e. \\some_server\C$.
MyFile.bat:
runas /user:mydomain\myuser “C:\Program Files\Microsoft Office\Office14\excel.exe \\myserver\path\to\file\myfile.xlsx”
If the excel fila has an auto_load macro it’s possibile to execute an update and close the file saving changes automatically.
Links:
https://www.hw-group.com/support/how-to-send-sms-via-hwg-sms-gw3
https://www.hw-group.com/accessory/sms-gw3
Methods of sending text messages:
Using netGSM (SOAP – HTTP POST)
Uploading a XML file using cURL
Uploading a XML file using PHP
Sending a SMS from Nagios
Using HTTP GET
Sending a SMS from Nagios
Sending a SMS using Wget
Sending a SMS using cURL
Sending a SMS from PRTG
Using the SNMP Write function
Sending text messages using the netGSM protocol
The netGSM protocol is based on SOAP; that is, sending a XML file using HTTP POST. For a description of the netGSM protocol, see: http://hw-group.us/product-version/netgsm
In a nutshell, HTTP POST is used to send a XML file (service.xml) with the following structure:
GsmOut
SMS
123456789
Hello World!
For a description of individual parameters, see the above-mentioned protocol description.
Uploading a XML file using cURL
cURL is a command-line tool to transfer data using protocols such as HTTP, FTP and more. cURL consists of two parts – the curl.exe console application, and the libcurl.dll library that implements all the curl functions.
The library can be used for writing your own scripts (bindings are available for many languages).
cURL is available free of charge at https://curl.haxx.se/ (https://curl.haxx.se/download.html) however, attention must be paid to choose the correct version to download.
The 32-bit version will not work in a 64-bit Windows environment, even though it starts OK!
cURL is started from the command line with the following command:
curl -X POST -T service.xml 192.168.100.169
where
-X defines the transfer method, in this case POST
-T specifies that a file is uploaded and what is its name (the file must be in the same folder as the curl.exe utility; otherwise, the path must be given)
IP address is the address of HWg-SMS-GW3
If the HWg-SMS-GW3 is secured with a username and a password, the credentials must be specified with the -u parameter:
curl -X POST -T service.xml -u user:pass 192.168.100.169
The response is:
C:\Users\volmr\Desktop\curl>curl -X POST -T service.xml -u user:pass 192.168.100.169
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 375 0 0 0 0 0 0 –:–:– 0:00:01 –:–:– 0
1
169
100 667 100 292 100 375 292 375 0:00:01 0:00:01 –:–:– 657
C:\Users\volmr\Desktop\curl>
Uploading a XML file using PHP
PHP is one of the most popular open source web scripting language. Sending a SMS from your own website is very simple; an example script follows:
GsmOut
“.$type.”
“.$nmr.”
“.$text.”
“;
$fp = @fsockopen($host, $port, $errno, $errstr, 30);
if (!$fp) {
echo “$host:$port: $errstr ($errno)\r\n”;
}
else {
fwrite($fp, “POST /service.xml HTTP/1.0\r\n”);
fwrite($fp, “User-Agent: MyPHPTest\r\n”);
fwrite($fp, sprintf(“Host: %s\r\n”, $host));
fwrite($fp, sprintf(“Authorization: Basic %s\r\n”, base64_encode($user . “:” . $pass)));
fwrite($fp, sprintf(“Content-Length: %d\r\n\r\n”, strlen($xml)));
fwrite($fp, $xml);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Simply fill out the address, username and password for your HWg-SMS-GW3 and everything works right away. The $type, $nmr and $text variables can be of course passed from other scripts.
Sending a SMS from Nagios
Nagios uses scripts written in Perl. The Netways company from Germany has provided the notify-poseidon-sms.pl script that can send up to 160 characters with this command:
./notify-poseidon-sms.pl -H 192.0.2.10 -M “Test message” -D 123456789
where:
-H – (Host) IP address of HWg-SMS-GW3
-M – (Message) message text
-D – (Destination) recipient’s telephone number
A limitation is that the script can only send SMS and cannot ring the recipient’s phone number; however, this can be easily changed, see e.g. notify-poseidon-call.pl (see the attachments). Also, it does not support http authentication.
Example of use in Windows:
C:\Users\volmr\Desktop\curl>perl notify-poseidon-sms.pl -H 192.168.100.169 -M “Hello World!” -D 777232759
OK, message sent with ID 1 to ‘777232759’
C:\Users\volmr\Desktop\curl>
Sending text messages using HTTP GET
HTTP GET is a method where all parameters are passed directly in the URL. This method is often used for simple applications because it allows for simple debugging and is easy to code. One simply invokes the address with the necessary parameters:
values.xml?Cmd=SMS&Nmr=00420123456789&Text=Hello World!
where:
Values.xml – file in the GW that the command should process. It is either values.xml or service.xml
Cmd – command that instructs what the GW should do: SMS – send a text message, CALL – ring the number
Nmr – phone number in national or international format. It is recommended to use 00 instead of the “+” sign so that there is no need to replace the “+” with an entity
Text – message text encoded in UTF-8
A disadvantage is that the HTTP GET method, natively used to display WWW pages, is difficult to secure against misuse (one would need to set WWW Security, which then prevents unrestricted browsing of the HWg-SMS-GW3 web interface).
And even then, the login credentials are sent in the URL in the open:
http://user:pass@192.168.1.1/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello 20World!
For these reasons, the sending of messages via HTTP GET is disabled by default, and must be manually enabled at the GSM Modem tab if it is needed:
Sending a SMS from a web browser
Enter the URL of HWg-SMS-GW3 including the requested commands into the address field of the web browser:
http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!
After sending, a XML confirmation appears:
1
2
Sending SMS using Wget
GNU Wget is a command-line utility that serves as a simple but powerful http client. It implements file transfer over HTTP, HTTPS and FTP protocols. It is available at https://www.gnu.org/software/wget/ and Windows versions are available at http://gnuwin32.sourceforge.net/packages/wget.htm
Wget is very simple to use – simply enter the same command that would be entered in the browser address field. However, the entire URL must be enclosed in double quotes:
wget “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”
The result looks like this:
C:\Users\volmr\Desktop\wget>wget “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”
–2017-12-28 15:56:35– http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello%20World!
Connecting to 192.168.100.169:80… connected.
HTTP request sent, awaiting response… 200 Ok
Length: unspecified [text/xml]
Saving to: ‘values.xml@Cmd=SMS&Nmr=777232759&Text=Hello%20World!.1’
values.xml@Cmd=SMS&Nmr=777232 [ <=> ] 118 –.-KB/s in 0s
2017-12-28 15:56:35 (5.48 MB/s) – ‘values.xml@Cmd=SMS&Nmr=777232759&Text=Hello%20World!.1’ saved [118]
C:\Users\volmr\Desktop\wget>
Sending SMS using cURL
The cURL utility is used in the same way as the wget utility. This is the command:
curl “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”
And this is the application’s response:
C:\Users\volmr\Desktop\curl>curl “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”
1
4
C:\Users\volmr\Desktop\curl>
Of course, the main result is that the message is sent.
Sending a SMS from PRTG
PRTG Network Monitor is a complex network monitoring solution that combines Paessler’s expertise with a complete set of monitoring functions, intuitive and easy-to-use UI and the most advanced monitoring tool suitable for all types of networks.
PRTG Network Monitor can send text messages using the HTTP GET method. The setting up only involves specifying a URL for sending the messages.
This is done with the Enterprise Console (application or WWW interface) in Setup > System Administration > Notification Delivery. The Custom URL field should contain:
http://IP_adresa/values.xml?Cmd=SMS&Nmr=%SMSNUMBER&Text=%SMSTEXT
This ensures that the SMSNUMBER and SMSTEXT system variables are inserted at the correct places in the URL.
PRTG currently does not support security using username and password!
Sending a SMS using the SNMP Write function (snmpset)
Starting from firmware version 1.1.3, HWg-SMS-GW3 supports the sending of SMS and dialing of numbers using SNMP. SNMP write, or more exactly SNMP SET function, is used for that purpose.
However, it is necessary to write all the 3 required OIDs for the recipient’s number, message text and function (SMS/ring/SMS+ring). The OIDs are the following:
msgQueueNmr (OID .1.3.6.1.4.1.21796.4.10.2.2.0) – (mandatory) Recipient’s phone number in national or international format. The international format can use either “+” or “00”.
msgQueueCmd (OID .1.3.6.1.4.1.21796.4.10.2.3.0) – (mandatory) Action: 1=sms, 2=ring, 3=sms+ring
msgQueueText (OID .1.3.6.1.4.1.21796.4.10.2.1.0) – (mandatory) Message text. Can be omitted if the requested action is ring only.
In a concrete example, the individual commands could look like this:
snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.1.0 s “Hello World!”
snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 1
When the commands are entered in the command line, the following appears:
C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
SNMPv2-SMI::enterprises.21796.4.10.2.2.0 = INTEGER: 777232759
C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.1.0 s “Hello World!”
SNMPv2-SMI::enterprises.21796.4.10.2.1.0 = STRING: “Hello World!”
C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 1
SNMPv2-SMI::enterprises.21796.4.10.2.3.0 = INTEGER: 1
C:\usr\bin>
The command to ring the number then looks like this:
snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 2
and the response:
C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
SNMPv2-SMI::enterprises.21796.4.10.2.2.0 = INTEGER: 777232759
C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 2
SNMPv2-SMI::enterprises.21796.4.10.2.3.0 = INTEGER: 2
C:\usr\bin>
This article shows how to configure Windows Time Service on Windows Server 2016 so that it acts as an NTP server for domain client computers.
1. Type the following commands on PowerShell:
w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:MANUAL
Stop-Service w32time
Start-Service w32time
Now the Windows Server 2016 is an NTP client of pool.ntp.org and its time/clock is synced with the NTP pool servers (The server is at the same time the NTP server for other domain client systems).
If your Windows Server 2016 machine is a VM inside Hyper-V, you have to disable time sync. Go to VM settings-> Management-> Integration Services and uncheck Time Synchronization. Otherwise, Windows Server 2016 time/clock will be synced with the Host time/clock.
2. Go to the client machines and run the following command on PowerShell to force them to sync their time/clock with the domain controller on the Windows Server 2016.
w32tm /resync
You can check the time synchronization status using the following command.
w32tm /query /status
This Powershell script executed with the correct rights:
Invoke-Command -ComputerName-ScriptBlock{Get-Service -Name MapsBroker | Set-Service -StartupType Disabled}
We can use net share command to create, configure and delete network shares from command line . Below you can find syntax and examples for net share command.
Create a network share from command line
The syntax for creating a share is as follows.
net share sharename=folderpath /grant:username,permissions sharename: You can assign name to the share you are going to create username : Login id of the user whom you want to share the folder with permission: Read, Change or Full
For example to share the folder E:\Docs with everyone in the domain and to give full permissions
net share Docs=E:\Documents /grant:everyone,FULL
If you are allowing multiple users to access the share, you can limit the number of users accessing the share simultaneously. This will prevent performance impact on your system. The below command will set the limit to 10 users.
net share Docs=E:\Documents /grant:everyone,FULL /users:10
Command to share with a specific user and to grant only read rights:
net share Docs=E:\Documents /grant:username,READ
Delete network share(i.e to disable sharing of the folder) from command line
net share sharename /delete
For example, to delete the share created above, the command would be as below.
net share docs /delete
Alternatively, we can use the folder physical location also to disable sharing
net share E:\Docs /delete
List the shared created on the local computer
net share
Delete the share on a remote computer
net share sharename \\remotepc /delete
function Get-MyDate{
[CmdletBinding()]
param(
[Parameter(Mandatory=$True,
ValueFromPipeLine=$True,
ValueFromPipeLineByPropertyName=$True,
HelpMessage="ComputerName or IP Address to query via WMI")]
[string[]]$ComputerName
)
foreach($computer in $computerName){
$timeZone=Get-WmiObject -Class win32_timezone -ComputerName $computer
$localTime = Get-WmiObject -Class win32_localtime -ComputerName $computer
$output =@{'ComputerName' = $localTime.__SERVER;
'Current Time' = (Get-Date -Day $localTime.Day -Month $localTime.Month);
}
$object = New-Object -TypeName PSObject -Property $output
Write-Output $object
}
}
get-mydate -ComputerName MyComputerName
with this powershell script we’ll be able to get share permissions and ntfs permissions form all the shares of our servers list.
Function GetSharedFolderPermission($ComputerName) { #test server connectivity $PingResult = Test-Connection -ComputerName $ComputerName -Count 1 -Quiet if($PingResult) { #check the credential whether trigger if($Credential) { $SharedFolderSecs = Get-WmiObject -Class Win32_LogicalShareSecuritySetting ` -ComputerName $ComputerName -Credential $Credential -ErrorAction SilentlyContinue } else { $SharedFolderSecs = Get-WmiObject -Class Win32_LogicalShareSecuritySetting ` -ComputerName $ComputerName -ErrorAction SilentlyContinue } foreach ($SharedFolderSec in $SharedFolderSecs) { $Objs = @() #define the empty array $SecDescriptor = $SharedFolderSec.GetSecurityDescriptor() foreach($DACL in $SecDescriptor.Descriptor.DACL) { $DACLDomain = $DACL.Trustee.Domain $DACLName = $DACL.Trustee.Name if($DACLDomain -ne $null) { $UserName = "$DACLDomain\$DACLName" } else { $UserName = "$DACLName" } #customize the property $Properties = @{'ComputerName' = $ComputerName 'SharedFolderName' = $SharedFolderSec.Name 'SecurityPrincipal' = $UserName 'FileSystemRights' = [Security.AccessControl.FileSystemRights]` $($DACL.AccessMask -as [Security.AccessControl.FileSystemRights]) 'NTFS' = 0} $SharedACLs = New-Object -TypeName PSObject -Property $Properties $Objs += $SharedACLs } $Objs|Select-Object ComputerName,SharedFolderName,SecurityPrincipal,FileSystemRights,NTFS } } else { $Properties = @{'ComputerName' = $ComputerName 'SharedFolderName' = "Not Available" 'SecurityPrincipal' = "Not Available" 'FileSystemRights' = "Not Available" 'NTFS' = 0} $SharedACLs = New-Object -TypeName PSObject -Property $Properties $Objs += $SharedACLs $Objs|Select-Object ComputerName,SharedFolderName,SecurityPrincipal,FileSystemRights,NTFS } } Function GetSharedFolderNTFSPermission($ComputerName) { #test server connectivity $PingResult = Test-Connection -ComputerName $ComputerName -Count 1 -Quiet if($PingResult) { #check the credential whether trigger if($Credential) { $SharedFolders = Get-WmiObject -Class Win32_Share ` -ComputerName $ComputerName -Credential $Credential -ErrorAction SilentlyContinue } else { $SharedFolders = Get-WmiObject -Class Win32_Share ` -ComputerName $ComputerName -ErrorAction SilentlyContinue } foreach($SharedFolder in $SharedFolders) { $Objs = @() $SharedFolderPath = [regex]::Escape($SharedFolder.Path) if($Credential) { $SharedNTFSSecs = Get-WmiObject -Class Win32_LogicalFileSecuritySetting ` -Filter "Path='$SharedFolderPath'" -ComputerName $ComputerName -Credential $Credential } else { $SharedNTFSSecs = Get-WmiObject -Class Win32_LogicalFileSecuritySetting ` -Filter "Path='$SharedFolderPath'" -ComputerName $ComputerName } $SecDescriptor = $SharedNTFSSecs.GetSecurityDescriptor() foreach($DACL in $SecDescriptor.Descriptor.DACL) { $DACLDomain = $DACL.Trustee.Domain $DACLName = $DACL.Trustee.Name if($DACLDomain -ne $null) { $UserName = "$DACLDomain\$DACLName" } else { $UserName = "$DACLName" } #customize the property $Properties = @{'ComputerName' = $ComputerName 'SharedFolderName' = $SharedFolder.Name 'SecurityPrincipal' = $UserName 'FileSystemRights' = [Security.AccessControl.FileSystemRights]` $($DACL.AccessMask -as [Security.AccessControl.FileSystemRights]) 'NTFS' = 1} $SharedNTFSACL = New-Object -TypeName PSObject -Property $Properties $Objs += $SharedNTFSACL } $Objs |Select-Object ComputerName,SharedFolderName,SecurityPrincipal,FileSystemRights,NTFS -Unique } } else { $Properties = @{'ComputerName' = $ComputerName 'SharedFolderName' = "Not Available" 'SecurityPrincipal' = "Not Available" 'FileSystemRights' = "Not Available" 'NTFS' = "1"} $SharedNTFSACL = New-Object -TypeName PSObject -Property $Properties $Objs += $SharedNTFSACL $Objs |Select-Object ComputerName,SharedFolderName,SecurityPrincipal,FileSystemRights,NTFS -Unique } } Function LetsStart($ComputerName){ foreach($CN in $ComputerName){ GetSharedFolderNTFSPermission -ComputerName $CN GetSharedFolderPermission -ComputerName $CN } } $ComputerName="server01","server02","server03" $CurrentDate = Get-Date $CurrentDate = $CurrentDate.ToString('yyyy-MM-dd_HH-mm') LetsStart($ComputerName) | Export-Csv “c:\path\to\file\$CurrentDate.csv" -NoTypeInformation
Recent Comments