Scripting Languages

28K

Solutions

21K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

Share tech news, updates, or what's on your mind.

Sign up to Post

SQL - Database snapshot.

Is there away to refresh snapshot database without dropping snapshot?
 
Today I was trying to add ldap group account to database snapshot without success.  I did want to drop source database because we only doing database refreshes at night.

So is there a query that can run against snapshot database to add domain group accounts?
0
Hi,

Is there a way to list the properties attribute in PowerShell?

Example: Get-AdUser user01 -properties...

I need to know which properties attributes existed. Is there a quick trick to list them?

Thanks
1
Hi,

In this Powershell cmd:

Get-AdUser -Identity $user

How can I make PowerShell prompt asking for user name? I want user provides the info about identity in variable.
1
Dear expert

In powershell, is it possible to invoke a variable in a variable? For exemple: $flower = ($color = "Red", leaf = "4", $weight = "50g") ?

Regards
Wei
1
ReactReduxCodeFile.rtfI'm a total react/redux newbie; I have a react/redux app that loads a page based on 2 sets of select boxes; When user makes selection, the dispatch event happens and immediately a spinning loader icon is displayed which displays until all the data is loaded. Somewhere in the attached file code, that part is not working. Any help is appreciated.
0
Hi Experts,

I've been working on this powershell script and need some help with a couple of things.  The script will be called from this vbscript to pass the computername or listofcomputers variables.

What I'd like expertise or help with is:

1. I've tested calling this from the VBScript Code in top comments section, but didn't get the computername variable to pass down.  (this would be done from the vbscript above, but wanted just a test wrapper to test).  EDIT:  If this is too difficult, I'd like to set it up to pull from a list of computers.

2. I'm first running "Test-MyConnection" (if) the computer is online, I'm then calling a executable.exe.  This is the part I'm having issues with - I don't necessarily want to run a .exe here, but call an SCCM advert (pasted below from client center), or, I also have a vbscript that runs the advert I could call out to.  This advert would exist locally on every computer.  The part I'm unsure about, or how to code is having this advert run on each computer in the list of variables


SCCM Advert Code:
 get-wmiobject -query "SELECT * FROM CCM_Scheduler_ScheduledMessage WHERE ScheduledMessageID='SCCM00001-SCCM00002-5D2960FE'" -namespace "ROOT\ccm\policy\machine\actualconfig"
 

Open in new window

0
We are trying to implement the Win 10 1809 STIG. Several of the checks in the STIG use Get-ProcessMitigation -Name PROGRAM.  Several checks are failing due to the PS command error below:
Get-ProcessMitigation -Name Acrobat.exe
Get-ProcessMitigation : Requested registry access is not allowed.
At line:1 char:1
+ Get-ProcessMitigation -Name Acrobat.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ProcessMitigation], SecurityException
    + FullyQualifiedErrorId : System.Security.SecurityException,Microsoft.Samples.PowerShell.Commands.GetProcessMitigationCommand

Open in new window

However, the following runs fine:
Get-ItemProperty -path 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Acrobat.exe'

DisableExceptionChainValidation : 0
MitigationOptions               : {1, 1, 33, 0...}
MitigationAuditOptions          : {0, 0, 0, 0...}
PSPath                          : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Acrobat.exe
PSParentPath                    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
PSChildName                     : Acrobat.exe
PSDrive                         : HKLM
PSProvider                      : Microsoft.PowerShell.Core\Registry

Open in new window

Get-ProcessMitigation -system also runs fine.  Get-ProcessMitigation without the -name is suppose to return all the program values, however that has the same registry error.  We are having a hard time trying to figure out how to fix this so we can get accurate results.
1
I'm able to print the label's fine but would like to have the first line 6pt Itallic, the second line 8pt bold, and the rest in 8pt.
My issue is simmaler to ..
https://www.experts-exchange.com/questions/29089661/Can-you-BOLD-part-of-text-you-want-to-show-in-a-PDF-using-FPDF-and-PDF-Label.html
But found no useful help.

 $text = sprintf(" %s            %s\n %s  %s\n %s\n %s  %s  %s", $id, $dueDate2, $firstN, $lastN, $address, $city, $state, $zip);
$pdf->Add_Label($text);

Open in new window


PDF_Label..

<?php
////////////////////////////////////////////////////////////////////////////////////////////////
// PDF_Label 
//
// Class to print labels in Avery or custom formats
//
// Copyright (C) 2003 Laurent PASSEBECQ (LPA)
// Based on code by Steve Dillon
//
//---------------------------------------------------------------------------------------------
// VERSIONS:
// 1.0: Initial release
// 1.1: + Added unit in the constructor
//      + Now Positions start at (1,1).. then the first label at top-left of a page is (1,1)
//      + Added in the description of a label:
//           font-size : defaut char size (can be changed by calling Set_Char_Size(xx);
//           paper-size: Size of the paper for this sheet (thanx to Al Canton)
//           metric    : type of unit used in this description
//                       You can define your label properties in inches by setting metric to
//                       'in' and print in millimiters by setting unit to 'mm' in 

Open in new window

0
Modify existing Powershell to delete Bak files  X number of days based on generated content  (csv log) report with function to send report after removal.

I need Powershell script to ready csv log "fullname" column and remove any bak files folder older then 5 days from remote servers (computername column).
Below i included script to generate that csv log report.  Perhaps this script can be modified to do what i need in the above description.

This is csv log report

#TYPE System.Management.Automation.PSCustomObject                        
ComputerName           Name          FullName                                Size              Created
RTDB101                  Brie.bak         \\RTDB101\E$\Brie.bak      939.40 MB      9/23/2019 15:16
RTDB101                  SFWT.bak        \\RTDB101\E$\SFWT.bak      2,729.45 MB      9/23/2019 15:16
CDB102                         RES.bak        \\CDB102\E$\RES.bak      4,343.22 MB      8/12/2018
CDB102                        DEW.bak      \\CDB102\E$\DEW.bak      1,245.87 MB      10/10/2019
RDER103             WERT.bak      \\RDER103\E$\WERT.bak      1,235.87 MB      5/23/2019 0:00
RDER103            WERTY.BAK      \\RDER103\E$\WERTY.BAK      935.40 MB      5/23/2019 0:00


This is the script to generate this report.

$ComputersPath = "C:\Audit\computers.txt"
$LogPath = "C:\Audit\"
$LogFile = Join-Path -Path $LogPath -ChildPath BakFileReport.csv
$sendMailMessageParams = @{
      Smtpserver = "xxxxx.xxxx.xxx.xxx.net"
      From =       "BackupFileChecks_noreplay@xxxx.com"
      To =         "xxxx.xxxxn@xxxx.com"
      CC =         "yyal.yyyyan@yyyyys.com"
      Subject =    "Database Backup …
1
Hello experts,

I was wondering how to display the wireless networks dialog box through AutoHotkey.
If you have advice on this please let me know.

Thank you for your help.
20191009_125719-screenshot.png
0
Hi,


Is possible in Citrix version 6 to get information about users session in csv file?

Let say I need to get at least info about username and application for all my Citrix farm servers (5) for all users sessions login for a week.

Is there a way to do that in Citrix or Cmd?

Thanks
0
Hello experts,

The following procedure allows me to remove extra blank lines.

^!Space::
  ; clipboard:="" ; Joe commented out - not needed because Ctrl+c replaces Clipboard
  ;~ Send, ^a ; Luis commented out because he prefers to select the block
  Send, ^c
  ClipWait,1 ; Joe added - good practice to do a ClipWait after Ctrl+c
  If (ErrorLevel=1)
  {
    MsgBox,4144,Error,No text appeared on clipboard after waiting for one second
    Return
  }
  Clipboard:=RegExReplace(Clipboard,"\R\R\K\R+") ; replace two or more consecutive blank lines with a single blank line
  sleep 100
  ; Joe: see if last two chars are CR and/or LF
  LastChar:=SubStr(Clipboard,0,1)
  If ((LastChar="`r") or (LastChar="`n"))
    StringTrimRight,Clipboard,Clipboard,1
  If ((LastChar="`r") or (LastChar="`n"))
    StringTrimRight,Clipboard,Clipboard,1
  
  Send, ^v
  Return

Open in new window


I noticed that removal is not performed when blank lines starts with a space.

Example of block text:

text


 
text with extra blank lines above.

Could you please help me to adjust the AutoHotkey to be able to remove extra blank lines even if they start with a space?

Thank you for your help.
0
Hi,

I'm trying to do a PowerShell script to get all users sessions connected in Windows terminal servers for 1 week.

So basically I will do schedule job which will run every 1h and takes users session (user name or login) and happen info in a csv file.

How can I do that?
1
Dear expert

Now to next question of the game blackjack powershell. About A card:

$A = 11
$2 = 2
$3 = 3
$4 = 4
$5 = 5
$6 = 6
$7 = 7
$8 = 8
$9 = 9
$10 = 10
$J = 11
$Q = 12
$K = 13
$Deck = @($A, $2, $3, $4, $5, $6, $7, $8, $9, $10, $J, $Q, $K)
$blackjack = 21

$Dealer = (Get-Random -InputObject $Deck) + (Get-Random -InputObject $Deck) 

if ($A + $dealer -lt $blackjack ){
$A = 11 }
else {$A = 1} 

While ($Dealer -lt 15) {
	Write-Host "Dealer draws a card!"
	$Dealer += (Get-Random -InputObject $Deck)
if ($A + $dealer -lt $blackjack ){
$A = 11 }
else {$A = 1} 
}
If ($Dealer -ge 15 -and $Dealer -le $blackjack) {
	Write-Host "Dealer stays"
	Break
}
If ($Dealer -gt $blackjack) {
	Write-Host "Dealer Lost!"
	Break
}
If ($Dealer -eq $blackjack) {
	Write-Host "Dealer wins! Blackjack!!!"
    Break
}

Open in new window


I added 2 if statement, one in start and one in the while loop, the question I got is, will this be right?
Thanks
0
Dear expert

I trying to build a blackjack in powershell, now this is just a beginning:
$A = 1
$2 = 2
$3 = 3
$4 = 4
$5 = 5
$6 = 6
$7 = 7
$8 = 8
$9 = 9
$10 = 10
$J = 11
$Q = 12
$K = 13
$Deck = @($A, $2, $3, $4, $5, $6, $7, $8, $9, $10, $J, $Q, $K)
$blackjack = 21

$Dealer = (Get-Random -InputObject $Deck) + (Get-Random -InputObject $Deck)

if ($Dealer -ge 15 -and $_ -lt $blackjack){
Write-Host "Dealer stays"
Break
}
if ($Dealer -lt 15){
do {
Write-Host "Dealer drag a card!"
$Dealer + (Get-Random -InputObject $Deck)
} 
Until ($Dealer -ge 15 -and $Dealer -lt 21)
}
if ($Dealer -gt $blackjack) {
Write-Host "Dealer Lost!"
Break
}

if ($Dealer -eq $blackjack) {
Write-Host "Dealer win! Blackjack!!!"
}

if ($Dealer -gt $blackjack) {
Write-Host "Dealer Lost!"
}
$Dealer

Open in new window


Its not finished yet, please do not finish it for me please. I will create more question about this powershell game, (I know I will need a if statement for card A, now that is something I will solve later on, because A is 1 or 13)

Anyway, first question that I encounter is the do loop, it doesn't seems working. I need the result to be: if dealers hand is lower than 15, then go in $deck array to add a variable, and stops until its more then $blackjack or more or equal than 15. This is not working, the loop seems infinite.

What did I do wrong here?
0
Hello,

I am trying to send a click to close document recovery pane button in excel .
The objective is to close the process through reading the image however for the moment I want to understand why click is not applied. I attached a video.
Could you please advice me on how the click should be performed?
I don’t know how to make the click work.


Thank you for your help.


:*:drx::
If (winactive("ahk_exe excel.exe"))
{
  
  WinMaximize
  Sleep, 200
  Click, left,235,1120,4
  Return
}
else
  MsgBox,4112,Fatal Error, Program not supported
Return

Open in new window



Thank you for your help.
20191003_175954-testing-document-reco.7z
0
Hello experts,

I was wondering if there is a way to mute and unmute sound through AutoHotkey.

Thank you for your help.

mute-unmute_20191003_113435.png
0
Need a PowerCLI Script that will do the following:

1.) Scan all the ESXi Hosts that are part of a VSAN Cluster in my Vcenter

2.) Get Only the Driver & Firmware information for the smartpqi Module

Module = smartpqi

Driver Version:

Firmware Version:

Driver Version:


3.) Display the results for each ESXi Host

4.) Optional - Maybe export the info to excel spreadsheet

Thanks  Really appreciate this!
1
A Script to add a new tab and field in Active Diretory Object Properties

I have Active Directory in LAB environment. I would like to add new tab with Fields under the tab.

Example the tab wil show as "Employee Info" , and under the tab , I will see fields such as Employee ID , Date of Hire, etc....

Thank you
0
Hello experts,

I set up the following AutoHotkey script on the basis of the following question:
https://www.experts-exchange.com/questions/29157425/Autohotkey-Open-edit-file-based-on-file-extension.html
+^F1::
FormatTime, CurrentDateTimeFileSelected,, yyyyMMdd_HHmmss
FileSelected:=GetSelectedFile()
SplitPath,FileSelected,FileNameSelected,FileDirectory,FileExtension
NewFileName:= SubStr(FileNameSelected,1, -5) . "_" . CurrentDateTimeFileSelected . "." . FileExtension 
;~ FileCopy, %FileSelected%, 
NewFile:=FileDirectory . "\" . NewFileName
Msgbox %NewFile%
FileCopy, %FileSelected%, %NewFile%

GetSelectedFile(hwnd="") {
; this function by sinkfaze: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=77#p395
 WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
 WinGetClass class, ahk_id %hwnd%
 if (process = "explorer.exe")
 if (class ~= "Progman|WorkerW") {
 ControlGet, files, List, Selected Col1, SysListView321, ahk_class %class%
 Loop, Parse, files, `n, `r
 ToReturn .= A_Desktop "\" A_LoopField "`n"
 }
 else if (class ~= "(Cabinet|Explore)WClass") {
 for window in ComObjCreate("Shell.Application").Windows
 if (window.hwnd==hwnd)
 sel := window.Document.SelectedItems
 for item in sel
 ToReturn .= item.path "`n"
 }
 return Trim(ToReturn,"`n")
}
Return

Open in new window


Prior to adding to my AutoHotkey file I have some questions:
1-I used the GetSelectedFile function in another AutoHotkey script declare in my AutoHotkey file. What is the best practice:
Have just a single function for the various AutoHotkey scripts that use it and place the function at the end of the file? Or declare the function every time when an AutoHotkey script use it? I supposed the first option is the best but I would like to have a confirmation.
2-Could you please confirm the structure of the AutoHotkey and if you have additional advice or another best way to copy and rename file please let me know. For example where should I add an error level condition?

I attached a video to illustrate that it works here in an OS 10.
Thank you for your help.
copy-rename-file_20190928_234539.7z
0
Hi All,

I am trying to write a powershell script to compare a list of files from a text file to a list of files in a folder. I currently have that working however I need to allow the search to allow a specific number of wildcard  characters in the filename.

So example:

List in text File:
c:\Folder\test1.txt
c:\Folder\test2.txt
c:\Folder\test3.txt

Files in Folder:
c:\Folder\test11.txt
c:\Folder\test222.txt
c:\Folder\test31.txt

Output Required:
Match test11.txt and test31.txt only

So in this example allow only 1 wildcard character compared to the list from the text file.

This is what I have thus far:

$FileCheck = get-content C:\compare.txt | ForEach {
      $_.TrimEnd(".txt")
}
ForEach ($File in $FileCheck)
{      
      if (test-path $file)
      { "$file YES">>C:\scripts\exists.log }
      else
      { "$file NO">>C:\scripts\doesnotexist.log }
}

Thank you in advance
1
Hello experts,

The following script allows me to send style code based on a selection:


!^c:: ;code
Send, ^x
Send, Sleep, 50 ClipWait,1 If (ErrorLevel=1) { MsgBox,4144,Error, No text appearing after one second Return } Send, ^v Sleep, 50 Send, {End} Sleep, 50 Send, Return


Instead of selecting and go to initial position I thought that the best is to simplify it as following through using directly by the clipboard:


!^c:: ;code
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
Clipboard:="" . ClipboardVar . ""
Sleep, 50
MsgBox,4160,Success,Your clipboard has been properly copied.
Return


Prior to adding to my AutoHotKey file could you please let me know your advice on the script structure and if I can go ahead by adding this on my AutoHotKey file.

Thank you very much for your help.
0
I am trying to build a query for Great Plains Dynamics but am running into some issues and cannot figure out why--I think it may be due to the JOIN commands I am using. When I do a search for a record for which I now there is only one I end up with 100's and 100's of query results, or errors so not sure what I am doing wrong. Here are the tables I need info from
SOP10100 is the Shipping Address Table
SOP10106 is the Shipping Details Table
SYO1200 is the email table
RM00102      MAIN Customer Info and ADDRESS Table

SOP10106 tied to SOP10100 by SOPNUMBE
SOP10100 tied to RM00102 by CUSTNMBR
RM00102 tied to SYO1200 by ADRSCODE

This is the script I generated using the SQL Server Enterprise Manager graphical "query" feature. This script does not generate any errors when I run it in SQL Enterprise Manager -- I know there is only one record that meets the criteria and yet it show more than 100 results. But when using SQL Query Analyzer I get these errors
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'SOP10106'.
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'SOP10100'.
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'RM00102'.
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'SY01200'.

Here is the script generated and used
SELECT SOP10106.SOPNUMBE, SOP10100.SOPNUMBE AS SOPNum, RM00102.CUSTNMBR, RM00102.ADRSCODE, SY01200.ADRSCODE AS ADRCOD, SOP10100.CUSTNMBR AS CSTMRNO

FROM SOP10106 INNER JOIN …
0
Hello experts,
I set up the following AutoHotkey to hide and show windows by class.
I took as a reference the AutoHotkey reported at https://www.experts-exchange.com/questions/29159194/AutoHotkey-WinHide.html#a42949009
:?*:hhx::
HideClass:="Chrome_WidgetWin_1" ; title must contain this - case insensitive
WinGet,AllWindows,List ; get list of all windows that exist
NumWin:=AllWindows ; number of all windows
NumHidden:=0 ; number of windows hidden
Loop,%NumWin% ; loop through all windows
{
  Handle:=AllWindows%A_Index% ; get the handle of each window
  WinGetClass,Class,ahk_id %Handle% ; get the class of each window
  If (InStr(Class,HideClass)) ; "contains" match and case insensitive
  {
    WinHide, ahk_class %Class% ; hide the window if it matches
    NumHidden:=NumHidden+1 ; increment number of windows hidden
  }
}
MsgBox,4160,Number Hidden: %NumHidden%,Done hiding windows that contain this in the Class:`n`n%HideClass%
Return

:?*:ssx::
DetectHiddenWindows,On ; so that WinGet finds the hidden windows
ShowClass:="Chrome_WidgetWin_1" ; Class must contain this - case insensitive
WinGet,AllWindows,List ; get list of all windows that exist
NumWin:=AllWindows ; number of all windows
NumShown:=0 ; number of windows shown
Loop,%NumWin% ; loop through all windows
{
  Handle:=AllWindows%A_Index% ; get the handle of each window
  WinGetClass,Class,ahk_id %Handle% ; get the class 

Open in new window

0
Hi

I am having problem to run this script against multiple servers and selected drives.
For some reason this script checks bak files only for one drive and one server.


Also i would like to be able to send an email with attachement.

Can you please help me to resolve this matter?

$ComputersPath = "e:\utils\computers.txt"
$LogPath = "e:\utils"

$Log = @()
ForEach ($Computer in (Get-Content $ComputersPath))
{   If ($Computer)
    {   ForEach ($Drive in "E","F","I","G")
        {   If (Test-Path "\\$Computer\$($Drive)`$\" -ErrorAction Stop)
            {   $Log += ForEach ($BAK in ($BAKS = Get-ChildItem "\\$Computer\$($Drive)`$\" -Include *.bak -Recurse -Force -erroraction SilentlyContinue))
                {   New-Object PSObject -Property @{
                        ComputerName = $Computer
                        Path = $BAK.DirectoryName
                        FileName = $BAK.BaseName
                        Size = "{0:N2} MB" -f ($BAK.Length / 1mb)
                    }
                }
            }    
        }
    }
}

$Log | Export-Csv $LogPath\BAKAUDITLog.csv -NoTypeInformation
1

Scripting Languages

28K

Solutions

21K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.