I was converting one of my AD solutions from PowerShell to Python (hobby that I have developed recently to pass time on holidays )
That solution required getting current DC & current directory which I have found is available in os library.
So, I thought lets blog about all the common things that you can do with this library, as these are common values required in day-to-day scripting.
How to fetch the domain name, domain controller, hostname, current directory, current login etc.?
Get Logon Domain Controller:
Get Current User:
You will be able to get pretty much everything you can get with set command on cmd.
Get Current Working Directory:
To find all the commands in OS module just type dir(os):
os library is very handy for a system administrator working with python.
I hope examples I have quoted here are helpful for the community.
Thanks for reading …