Tag: server


Add Azure CentOs server to Domain


Joining a Linux machine to a Windows domain is not straight forward.

You will need to connect to the server via an SSH app (f.eks Putty)

  1. Sign-in with the admin and password you created when deploying the server
  2. To do some of the commands you will need to be ROOT, but you don’t know this password, so run the following command: sudo -i
    enter the password for the adm account you created
  3. Install realm: yum install realm realmd -y
  4.  Add to domain: realm join yourdomain.com –user youradmin@yourdomain.com
     If you get error: realm: Couldn’t join realm: Necessary packages are not installed: oddjob, oddjob-mkhomedir, sssd, samba-common-tools, you need to install the missing packages.
    f.eks: yum install oddjob -y 

And now the machine is in the domain

 

 

 


Get system uptime


We all have our own ways of finding a servers / computers uptime.
But I thought I’d share my favorite way:

 

function Get-SrvUptime
{
$operatingSystem = Get-WmiObject Win32_OperatingSystem
[Management.ManagementDateTimeConverter]::ToDateTime($operatingSystem.LastBootUpTime)
}


Restarting a service with Task Scheduler


Some times you need to scheduler a restart of services on servers or computers, and I used to do this via a batch job, that I called from Task Scheduler, but..

I found a much easier way of doing this,  just create a new task, and add the Actions like bellow.

NET as the program, and START/STOP “SERVICENAME” as the argument

and voila, there it is 🙂


No more download 1 GB Test files


Tired of looking on the web for a big test file, or creating your own locally?
Then this is perfect for you too 🙂
Open CMD in administrator mode
Run the following command:
fsutil file createnew <file> <size in bytes>
F.eks this will create a 10 GB file in my tmp folder:
fsutil file createnew c:\tmp\10gb.test 10737418240
The key is to input the size of the file in bytes so here are some common file sizes to save you from math:
1 MB = 1048576 bytes
100 MB = 104857600 bytes
1 GB = 1073741824 bytes
10 GB = 10737418240 bytes
100 GB =107374182400 bytes
1 TB = 1099511627776 bytes
10 TB =10995116277760 bytes