Quick and Dirty install of OpenSSH under Windows Server 2012R2 to obtain SFTP/SSH login.
Often overlooked is the ability to schedule a task to run at system start. Utilizing that, you can use any number of ways to craft and send an email upon system reboot.
You can Google for a list of free smtp command line mailers to send the email or just use Blat which I’ve used for a while and works just fine.
Here’s a sample blat cmdline which can be added to a batch script or used directly in the task scheduler.
c:\utils\blat.exe -to firstname.lastname@example.org -f Sender@mydomain.com -server smtp.mydomain.com -subject "Server Reboot" -body "%computername% has been rebooted."
If you want to use a mailer that’s a little more robust & includes CC,BCC, and support for SSL/TLS (can be used with gmail) and other little things, check out Send-It-Quiet (src/bin avail via Github). And a 3rd option that also supports TLS is sendEmail.
The key is to simply use task scheduler…there are quite a few delivery methods and scripts including using Powershell like this person has.
I ended up not getting this to work perfectly but thought I’d post the draft as some of it may provide a little guidance..
- MS Network client [Disk1] [Disk2]
- AMD PCnet NDIS2 driver (vmware nic) [wfw31.zip]
- MS-Dos 6.22, bootable as cd [ISO]
- Folder2ISO [v2]
- netshar.exe [MS] [3rd Party MS Software Lib Mirror] – optional
Tiny, a Remote control TSR – optional
Create a folder to hold the contents of a mountable iso image (ie, c:\build\)
Extract (unzip) the two network disks into a single folder (c:\build\netsetup\)
Extract the AMD PCnet driver into the same folder (c:\build\netsetup\) via unzip, then run or extract the wfw31.exe to get the files needed.
Extract Tinyhg_f.exe from TinyHost.zip into the same folder also. this version includes support for VGA modes. If you don’t need VGA, then use the Tinyh_f.exe as it’ll use less memory)
Copy the netshar.exe into the same folder as well.
Run Folder2ISO and create an image of the netsetup folder.
Create a New VM (Install the OS later; type=Other, MS-Dos; Max HD Size=2G, store as a single file). Do not start the VM just yet, finish the new vm wizard. Set the Network type to be Bridged instead of NAT. Attach the Dos bootable ISO then manually EDIT your new vm’s vmx file using notepad++ or similar and ADD
bios.bootDelay = “nnnn”
I chose 5000 (in place of nnnn) for an approximate 5 second bios boot screen delay which will allow you time to hit the appropriate key to manually select a boot device.
NOW you can start up the VM, and it should automatically boot to the loaded ISO (dos6.22). When it’s up, run Fdisk to partition the HD. It will ask for a reboot.
When you restart, this time you’ll need to hit the appropriate key to bring up your bootmenu (on HP or Dell systems, it’s often ESC or F12.) and boot to the dos cd. Now format it and transfer the system files (/s), msdos files, and copy a barebones config that will load the cdrom driver.
format c: /s
xcopy r:\*.* c:\msdos\ /s /y
copy autoexec.bat c:\
copy config.sys c:\
copy himem.sys c:\
copy cd1.sys c:\
Power off the vm then change the attached ISO to the NetSetup.iso you created earlier and start up the vm again.
Change to the R: drive (cd rom) and run setup.exe to start the network client installation.
Accept default of c:\net
Select *Network adapter not shown on list below …
Accept Default location of R:\ then select the Advanced Micro Devices PCNET Family adaptor.
When entering your username, it will also be used as the PC name
Change network configuration
Tab to the upper box and highlight “NWLink IPX Compatible Transport”. Tab to the the lower box, select Remove, and then select the Microsoft TCP/IP for the protocol used.
Network setup is done. Press F3 to exit without rebooting.
Copy the file that allows for sharing folders and also copy and add the Tiny host; and set it to start at bootup
copy r:\netshar.exe c:\msdos
copy r:\tiny*.exe c:\msdos – Copies the Tiny remote control TSR from the network setup disc. c:\msdos\edit c:\autoexec.bat
c:\msdos\tinyhg_f.exe password password …or tinyh_f.exe for non-vga purposes
While your editing the autoexec.bat file, you’ll probably wish to verify a path statement exists and that c:\msdos, c:\, and c:\net are included. You can change the prompt also..
after saving and exiting, you can reboot the vm via Ctrl-Alt-Insert
Display your current hostname: $ uname -a
As admin/su, edit the hostname and hosts files:
(ie: newhostname.local.name OR newhostname)
change originalname to newhostname
[Situation]: Win7Pro-x64 already installed and running for a few years on an Athlon X2 4400. I got a new motherboard and i5-2500k, put old hd in new machine and booted. Everything popped up just fine and running great. oops..almost… My old system was running IDE and new mobo was set for IDE as well so I didn’t noticed it right off the bat.
Why do I want to change? ACHSI supports NCQ (Native Command Queuing) which should spped my system up a tad bit more! 🙂
So.. How do I switch to ahci w/o having to re-install Win7. Flipping it on in BIOS leaves me unbootable.
[Solution]: GIYF. UnNecessary drivers are disabled by default after a Win installation. We just need to turn the ahci detection on via the registry.
Save to *.reg file and import. 🙂
Windows Registry Editor Version 5.00
fyi: pciide Start was originally set to 00000003 but if you should have problems simply change the BIOS back to IDE mode.
Her’s a good little walkthru on Brian Lee Jackson’s site
/usr/sbin/lpadmin -p tms-copier-room18-01 -E -v lpd://tms-copier-room18-01 -P /Library/Printers/PPDs/Contents/Resources/en.lproj/CNR5050X1.PPD.gz -o printer-is-shared=false -D “tms-copier-room18-01 (Office)”
In Applescript you’ll need to use double quotes, etc.
do shell script “/usr/sbin/lpadmin -p tms-copier-room18-01 -E -v lpd://tms-copier-room18-01 -P /Library/Printers/PPDs/Contents/Resources/en.lproj/CNR5050X1.PPD.gz -o printer-is-shared=false -D ”tms-copier-room18-01 (Office)”“
If you have spaces in the driver name or elsewhere, be sure to preface them with a space. The below example uses a fictitious canon imagerunner example (the real ppd is not named as such)
do shell script “/usr/sbin/lpadmin -p Canon_Imagerunner -E -v lpd://tms-copier-room18-01 -P /Library/Printers/PPDs/Contents/Resources/en.lproj/Canon Imagerunner 4100.gz -o printer-is-shared=false -D ”tms-copier-room18-01 (Office)”“
to delete a printer, use the -x command.
/usr/sbin/lpadmin -x “name of printer”
Be sure to checkout the full list of options via the lpadmin man page. From terminal:
and remember, the do shell script command uses sh as the default shell, not bash.