Coder Social home page Coder Social logo

franklesniak / sysadmin-accelerator Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 3.0 369 KB

Sysadmin Accelerator is a set of reusable, reliable code that is useful for systems administration and related tasks

License: MIT License

VBScript 100.00%
sysadmin-scripts sysadmin sysadmins scripts-collection script scripts vbscript-script vbscript powershell-scripts powershell

sysadmin-accelerator's People

Contributors

franklesniak avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

sysadmin-accelerator's Issues

Add support for querying BIOS version

It'd be great if SAA could query BIOS version information.

In Windows, the best way to do this seems to be:
Win32_BIOS -> smbiosbiosversion
and some people say Win32_BIOS -> releasedate is more reliable

There are other properties of interest, too:
biosversion (more of a display name, returns multiple strings in an array)
smbiosmajorversion (not sure how useful this is)
smbiosminorversion (not sure how useful this is)

Add a function that converts a string into .NET-compatible, escaped RegEx

For example:

Function ConvertToDotNetEscapedRegEx(ByVal strInputString)
    Dim arrRegexCharactersToEscapeWithBackslash
    Dim strEscapedString
    Dim intCounterA

    ' Source: https://learn.microsoft.com/en-us/dotnet/standard/base-types/character-escapes-in-regular-expressions
    ' Also verified through testing in PowerShell
    arrRegexCharactersToEscapeWithBackslash = Array("\", ".", "$", "^", "{", "[", "(", "|", ")", "*", "+", "?", "#", " ")

    strEscapedString = strInputString
    
    For intCounterA = 0 To UBound(arrRegexCharactersToEscapeWithBackslash)
        strEscapedString = Replace(strEscapedString, arrRegexCharactersToEscapeWithBackslash(intCounterA), "\" & arrRegexCharactersToEscapeWithBackslash(intCounterA))
    Next

    ' strEscapedString = Replace(strEscapedString, Chr(7), "\a") ' Not necessary; PowerShell 7.2.x on Windows 11 does not encode this character
    ' strEscapedString = Replace(strEscapedString, Chr(8), "\b") ' Not necessary; PowerShell 7.2.x on Windows 11 does not encode this character
    strEscapedString = Replace(strEscapedString, vbTab, "\t") ' Chr(9)
    ' strEscapedString = Replace(strEscapedString, vbCrLf, "\n")
    strEscapedString = Replace(strEscapedString, vbLf, "\n") ' Chr(10)
    ' strEscapedString = Replace(strEscapedString, Chr(11), "\v") ' Not necessary; PowerShell 7.2.x on Windows 11 does not encode this character
    strEscapedString = Replace(strEscapedString, Chr(12), "\f") ' Chr(12)
    strEscapedString = Replace(strEscapedString, vbCr, "\r") ' Chr(13)
    ' strEscapedString = Replace(strEscapedString, Chr(18), "\e") ' Not necessary; PowerShell 7.2.x on Windows 11 does not encode this character

    ConvertToDotNetEscapedRegEx = strEscapedString
End Function

Create a function that gets the user's profile path

To get this path on Windows 9x, make sure profiles are enabled. Then, query:
Key: HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
Value name: Desktop

Then strip off the last folder name, which would be the localized name of the Desktop folder

Create a function that gets the local appdata folder

Something along these lines:

Const LocalAppDataIdentifier = &H1C&
Dim objShellApplication
Dim objShellApplicationFolder
Dim objShellApplicationFolderItem
Dim strLocalAppData
On Error Resume Next
Set objShellApplication = CreateObject("Shell.Application")
If Err Then
On Error Goto 0
Err.Clear
Set objShellApplication = Nothing
strLocalAppData = ""
If DEBUG_ON = True Then
WScript.Echo("WARNING: Unable to create Shell.Application object. This may because Internet Explorer 4.0 or newer is not installed. Also, unable to determine the path to Local AppData.")
End If
Else
Set objShellApplicationFolder = objShellApplication.NameSpace(LocalAppDataIdentifier)
If Err Then
On Error Goto 0
Err.Clear
strLocalAppData = ""
If DEBUG_ON = True Then
WScript.Echo("WARNING: Unable to determine the path to Local AppData.")
End If
Else
Set objShellApplicationFolderItem = objShellApplicationFolder.Self
If Err Then
On Error Goto 0
Err.Clear
strLocalAppData = ""
If DEBUG_ON = True Then
WScript.Echo("WARNING: Unable to determine the path to Local AppData.")
End If
Else
strLocalAppData = objShellApplicationFolderItem.Path
If Err Then
On Error Goto 0
Err.Clear
strLocalAppData = ""
If DEBUG_ON = True Then
WScript.Echo("WARNING: Unable to determine the path to Local AppData.")
End If
Else
On Error Goto 0
If TestObjectIsStringContainingData(strLocalAppData) <> True Then
strLocalAppData = ""
If DEBUG_ON = True Then
WScript.Echo("WARNING: Unable to determine the path to Local AppData.")
End If
Else
If Right(strLocalAppData,1) <> "" Then strLocalAppData = strLocalAppData & ""
End If
End If
End If
End If
End If
' objShellApplicationFolderItem and objShellApplicationFolder don't need to stick around
Set objShellApplicationFolderItem = Nothing
Set objShellApplicationFolder = Nothing

WScript.Echo(strLocalAppData)

GetTPMInfo() and GetTPMInfoSimpleBoolean() indicate enabled/activated/ready status unknown when no TPM present

When there is no TPM present, both GetTPMInfo() and GetTPMInfoSimpleBoolean() should pass status back to the caller that indicate that there is no enabled/activated/ready TPM.

This issue is caused by TestTPMInstancesForActivatedTPMUsingTPMInstances(), TestTPMInstancesForNonActivatedTPMUsingTPMInstances(), TestTPMInstancesForDisabledTPMUsingTPMInstances(), TestTPMInstancesForEnabledTPMUsingTPMInstances(), TestTPMInstancesForNonReadyTPMUsingTPMInstances(), and TestTPMInstancesForReadyTPMUsingTPMInstances() returning unknown status because they cannot connect to the WMI TPM namespace when there is no TPM present.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.