iamtheky Posted July 22, 2015 Share Posted July 22, 2015 (edited) *Requires Win 8 or higher, unless there is someway to import the DISM module in lower versions I am unaware of.As my last thread of powershell efforts was aimed at AD, so this one will be aimed at the DISM module available in Win 8 and above. Lets begin:This is the DISM image info command, via powershell, returning an array.#RequireAdmin #include <AutoItConstants.au3> #include <Array.au3> $sImagePath = 'C:\Users\username\Desktop\WIMs_2008\install.wim' $sCommands = "powershell get-WindowsImage -ImagePath " & $sImagePath $iPID = run($sCommands, "", @SW_HIDE , $stdout_child) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $aOutput = stringsplit($sOutput , @CR , 2) For $i = ubound($aOutput) - 1 to 0 step - 1 If stringleft(stringstripws($aOutput[$i], 1) , 1) = "" Then _ArrayDelete($aOutput, $i) Next _ArrayDisplay($aOutput) Edited July 24, 2015 by boththose no need for comspec ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Administrators Jon Posted July 22, 2015 Administrators Share Posted July 22, 2015 (edited) You probably want to add "-ExecutionPolicy Bypass -NoLogo" to the command line so that it will work on machines where the execution policy is restricted (the default).Edit: Scratch that, you are running a cmdlet not a script. Edited July 22, 2015 by Jon Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
iamtheky Posted July 22, 2015 Author Share Posted July 22, 2015 (edited) I'm working backwards (and slowly), I had high hopes of jumping right into importing your .ps1 and writing powershell scripts that include autoit goodness. But apparently I suck something fierce at that. This way it is at least functional.* An example of using the executionpolicy bypass in this manner to import a custom module, in case someone wants to know more about what Jon was recommending: https://www.autoitscript.com/forum/topic/166618-autoit-ing-the-powershell-command-line/?do=findComment&comment=1242799 Edited July 22, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
iamtheky Posted July 24, 2015 Author Share Posted July 24, 2015 (edited) CIM (building block of WMI) just got a bit easier, here is just the antecedent property from LoggedOnUser.#requireadmin ;get all logged on users $iPid = run("powershell Get-CimInstance -Class Win32_LoggedOnUser | select antecedent" , "" , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd msgbox(0, '' , $sOutput) Edited July 24, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
iamtheky Posted July 27, 2015 Author Share Posted July 27, 2015 Event log is kind of slow for retrieving a list of all users who have ever accessed a system, so finding other ways:Quick return of all user/domain strings to access the system#include<Array.au3> #RequireAdmin $iPid = run("powershell get-CimInstance Win32_SystemUsers -Property *" , "" , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $aOutput = stringsplit($sOutput , @CR , 2) _ArrayDisplay($aOutput)all local user profiles and the date of their last access#include<Array.au3> #RequireAdmin $iPid = run("powershell get-CimInstance Win32_UserProfile -Property *" , "" , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $aOutput = stringsplit($sOutput , @CR , 2) _ArrayDisplay($aOutput) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
iamtheky Posted July 28, 2015 Author Share Posted July 28, 2015 Getting Info from your current windows install, these actions require redirection to be turned off.WindowsEdition, WindowsDriver, WindowsOptionalFeature, WindowsPackageexpandcollapse popup#include<Array.au3> #RequireAdmin DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) $sOutput = "" $iPid = run("powershell get-WindowsEdition -online" , "" , @SW_HIDE , 0x2) While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $iPid = run("powershell get-WindowsDriver -online" , "" , @SW_HIDE , 0x2) While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $iPid = run("powershell get-WindowsOptionalFeature -online" , "" , @SW_HIDE , 0x2) While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $iPid = run("powershell get-WindowsPackage -online" , "" , @SW_HIDE , 0x2) While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $aOutput = stringsplit($sOutput , @CR , 2) _ArrayDisplay($aOutput) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now