We help IT Professionals succeed at work.

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.

Hi All

We have a Powershell winSCP script to transfer Website Backup Dir to Domain UNC folder and  we want to delete the Website Backup files after the transfer.

Looking at the WinSCP tutorials we understood the following would work (What is wrong regarding the delete part)

see code

try
{
    # Load WinSCP .NET assembly
    Add-Type -Path "WinSCP\WinSCPnet.dll"
 
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = "hostname"
        UserName = "username"
        Password = "password"
        SshHostKeyFingerprint = "ssh-ed................................................="
    }
 
    $session = New-Object WinSCP.Session
 
    try
    {
        # Connect
        $session.Open($sessionOptions)
 
        # Download files
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
 
        $transferResult =
            $session.GetFiles("/Backup/*.txt", "\UNC Path\Websites Backup\*", $False, $transferOptions)

      # Delete External Files
        $session.RemoveFiles("*.txt")

 
        # Throw on any error
        $transferResult.Check()
 
        # Print results
        foreach ($transfer in $transferResult.Transfers)
        {
            Write-Host "Download of $($transfer.FileName) succeeded"
        }
    }
    finally
    {
        # …
0
I'm working on a powershell script that will check the status of certain system services every few minutes. If any of the services are in a stopped state, the script will send an email message to the team to investigate. I'm attempting to store the results of the cmdlet "Get-Service" in a variable and place the results in the body of the message. However I'm not getting the desired results. For example:
(Get-Service spooler) returns the following:
Status   Name               DisplayName
------   ----               -----------
Running  spooler            Print Spooler

If I attempt to store this to a variable, then call the variable from the powershell console, it looks okay but I get completely different results when using the cmdlet "Send-MailMessage". I get the following:

System.ServiceProcess.ServiceController

The only way I seem to be able to get around this is to output the results to a TXT file then store the TXT into a variable using get-content. But this seems a bit messy and there's probably a better way of doing this. Any thoughts? Thank you for your time.
0
I am encountering a weird error and its boggling my mind. Can you powershell experts please show me what i am doing wrong. I am trying to put together a foreach statement that will readd AD groups to an AD User object/Member. So whats odd is that if i used the below PS code it works manually but does not work with variables and the foreach code below. It errors our stating cant find identity. But why when i manually input the same identity that is looping through it errors our. So for example if i type:

Add-ADGroupMember - OPSC -Members 1078477

Open in new window


It works just fine.. I verify and the AD Group is added to member 1078477

But when i insert this with variables and a foreach statement it states it cant find the identity? I verify that whats looping through is correct by executing the variable by itself.

$adgroups = Get-Content -Path C:\Scripts\adgroups.txt
foreach ($group in $adgroups) { Add-ADGroupMember - $group -Members 1078477}

Open in new window


Ive been playing with foreach statements all day trying to finetune my PS skills and understand the difference between foreach and Foreach-Object and Get-Content and Import-CSV for my own knowledge.

foreach-statement-erro.pngadgroups.png
1
Powershell- Add AD Group to AD User by Distinguished Name

I have a list of 30+ AD Groups that i want add back to an AD User Object. Whats the best powershell script that will allow me to add these groups back to the user if i have a CSV file that has a list of all the AD Groups ind CN format with no header? I can add a header if need be.
1CN-names-for-AD-groups.png
0
Powershell Experts, question. I run this script to remove all AD Groups from users that are being off-boarded. Works great, the only  thing is that when it loops through, it asks me after each one it loops though. Even when i click yes to all it still goes on to the next group and asks permission again to remove. Am i missing a parameter or what am i doing wrong? I want it to loop through, remove all AD groups for the AD user object and not ask me if its OK to remove.


Get-ADUser $disableduser -Properties MemberOf | Select -Expand MemberOf | %{Remove-ADGroupMember $_ -member $disableduser}

Open in new window


Remove-All-AD-Memberships-yes-to-all.png
1
Hello:

I have tried several different ways of combining my two CTEs within one "UNION ALL" statement but am having no luck.

How do I modify my syntax below to accomplish this?

Thank you!

Software Engineer

; with wip as 
(
select NULL as [LOTSEQNBR], FG.BatchNo as [FGBATCH], FG.FormulaId as [FG], FG.[Labor Cost] as [FGLABOR], FG.[OverHead Cost] as [FGOH], 
FG.[Material Cost] as [FGMAT], FG.[Labor Cost] + FG.[OverHead Cost] + FG.[Material Cost] as [FGCOST], FG.[TotalFGWeightYielded] as [FGWEIGHT], 
FG.[Labor Cost]/FG.[TotalFGWeightYielded] as [LABORLB],
FG.[OverHead Cost]/FG.[TotalFGWeightYielded] as [OHLB],
FG.[Material Cost]/FG.[TotalFGWeightYielded] as [MATLB],
NULL as [FORMULA], NULL as [FORMULAMAT], NULL AS [FORMULALABOR], NULL AS [FORMULAOH], NULL AS [Component], NULL as [LOT], NULL as [LOTQTY], 
NULL as [LOTMATUNITCOST], NULL as [LOTMATWIPCOST]
from BM_View_Dashboard_ProductionCostAnalysis FG
INNER JOIN BM010115 BOM ON FG.FormulaId = BOM.PPN_I
where FG.FormulaId = '506' and FG.BatchNo = '50418G12D' and BOM.SUBCAT_I = 1)
select [LOTSEQNBR], [FGBATCH], [FG], [FGLABOR], [FGOH], [FGMAT], [FGCOST], [FGWEIGHT], [LABORLB], [OHLB], [MATLB], [FORMULA], [FORMULAMAT], [FORMULALABOR], 
[FORMULAOH], [Component], [LOT], [LOTQTY], [LOTMATUNITCOST], [LOTMATWIPCOST],
[LABORLB]*[LOTQTY] as [LOTLABORWIPCOST],
[OHLB]*[LOTQTY] as [LOTOHWIPCOST]
from wip
; with wiplot as 
(
select * from (
select DISTINCT LOT.SLTSQNUM AS [LOTSEQNBR], NULL as [FGBATCH], NULL as [FG], NULL 

Open in new window

0
How do I add a conditional for the ipAddress.

if IpAddress -eq "-" do not count it or do not add it into the csv. See attachment

Get-WinEvent -FilterHashTable @{LogName='Security'; ProviderName='Microsoft-Windows-Security-Auditing';id=4624; StartTime="3/28/20"; EndTime="3/30/20"} | ForEach-Object {
	$xml = [xml]$_.ToXml().Replace('xmlns', 'dummy')
	$_ | Select-Object -Property TimeCreated, MachineName,`
	 @{n='TargetUserName';	e={"$($xml.SelectSingleNode("Event/EventData/Data[@Name='TargetDomainName']").InnerText)\$($xml.SelectSingleNode("Event/EventData/Data[@Name='TargetUserName']").InnerText)"}},
	 @{n='LogonType'; e={$xml.SelectSingleNode("Event/EventData/Data[@Name='LogonType']").InnerText}},
	 @{n='WorkstationName'; e={$xml.SelectSingleNode("Event/EventData/Data[@Name='WorkstationName']").InnerText}},
	 @{n='IpAddress'; e={$xml.SelectSingleNode("Event/EventData/Data[@Name='IpAddress']").InnerText}},
	 @{n='IpPort'; e={$xml.SelectSingleNode("Event/EventData/Data[@Name='IpPort']").InnerText}}
	} | Export-Csv D:\ger\SCRIPTS\EventID_4624.csv -nti

Open in new window

EventID_4624---Copy.csv
0
Hello I have enable audit policies in our domain and would like to read the Message content of the security log and grab the New Logon and Network Information fields

I am executing the following script

Get-WinEvent -Computername DomainController01 -FilterHastTable @{logname='security';ProviderName='Microsoft-Windows-Security-Auditing';id=4624;StartTime="3/27/20";EndTime=3/28/20"}

or by using Get-EventLog

Open in new window


See screenshot, how do i grab the individual properties or some properties from the Message section ?

Thanks for your help,
Screen-Shot-2020-03-27-at-5.54.44-PM.png
0
I have a WinSCP batch file that I am trying to utilize for uploading a file.  The batch when run does open, but logs in only and does not upload the file or exit even from the script.  Just keeps the window open.  Any help would be greatly appreciated.  Attaching file.
71142Orders.txt
0
Hi Experts,

If you go to www.iwscc.ca you will see in the header 2 orange buttons: Corporate and Self-Registration, both going to #

Under WP Admin, I see that this theme is called Nonprofit, and the buttons are set in Theme Options >Address Bar, and ou will see in the snapshot that I can set the buttons label, but not the url. My questions are...

1- How do I remove the Corporate button? If I leave it blank, I just get an orange square.

2- How can I actually set an url to these?

I know I can create a child theme, and address #1 with CSS and #2 with JS, but I think there should be an easier way since the theme provides these buttons.

BTW- even though in the screenshot it says Webdivia, under themes it says Nonprofit. I just inherited this website.

Thank you,
wp admin
0
Dear experts

I been working work stastic of corona virus, this script below is not working, whenever I run this, it says,
this row. $out[$header[$i++]] = $_.InnerText.Trim() cannot be null, now I didn't make any change of the script so I think the problem should be on web that it changed something, but then I noticed that in the webside they added yesterday data and today data, that might break the index of counting. Anyone know how to fix this?

Thanks

$credential = Import-CliXml -Path 'C:\test\cred.xml'
[System.Net.ServicePointManager]::SecurityProtocol = `
[System.Net.SecurityProtocolType]::Tls11 -bor
[System.Net.SecurityProtocolType]::Tls12 -bor `  
[System.Net.SecurityProtocolType]::Tls -bor `
[System.Net.SecurityProtocolType]::Ssl3

$title = 'Corona Virus spread'
$time = (Get-Date).ToString("yyyy-MM-dd HH:mm")
$attachment = 'C:\test\corona.html'
$url = "https://www.worldometers.info/coronavirus/#countries"
$countries = 'Sweden', 'China', 'Iran','USA', 'Italy', 'Finland', 'Norway', 'Denmark', 'Russia', 'UK', 'Spain', 'Thailand', 'Canada', 'India', 'France', 'Germany'
# Available properties: 'Country,Other', 'TotalCases', 'NewCases', 'TotalDeaths', 'NewDeaths', 'TotalRecovered', 'ActiveCases', 'Serious,Critical', 'Tot Cases/1M pop'
$properties = 'Country,Other', 'TotalCases', 'Tot Cases/1M pop','ActiveCases','Serious,Critical','TotalDeaths' , 'TotalRecovered' 

$htmlHead = @'
<style>
body {background-color:white; font-family:verdana; font-size:32px;}
table

Open in new window

1
Looking for a script that can be used remotely to kill a specific process for a specific user on any server in the Citrix farm.  
Also is it possible that there can be an Input Box that I can enter the Username and process name?

Thanks in advance.
1
I have a script  to collect logs. I want to collect more files residing at a different file location.I am using $logpath as a variable. Can anyone guide please.


$Logshare = "\\share\CMLogShare\"
#Get path for SCCM client Log files
$Logpath = Get-ItemProperty -path "C:\Windows\CCM\Logs"
$Log = $logpath

#Create folders
New-Item -Path $env:temp\SCCMLogs -ItemType Directory -Force
Copy-item -path $log\* -destination $env:temp\Sccmlogs -Force
0
Hi,

I run this PowerSell cmd in O365:

Set-UnifiedGroup $groupName -UnifiedGroupWelcomeMessageEnabled:$false

But how can do the contrary with Get-UnifiedGroup?

I want to see the status of: UnifiedGroupWelcomeMessageEnabled
0
Dear expert

Im trying to send a file to ftp using winSCPnet.dll it not working I got output:

Exception calling "Open" with "1" argument(s): "Connection failed.
Connection failed."
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

I could not find anything wrong with the code below, I tried with winscp to connect that worked, so it was not connect problem. Anyone know how to I can send a file to FTP using Powershell?

Thnx

Add-Type -Path "C:\Users\sewetia001\AppData\Local\Programs\WinSCP\WinSCPnet.dll"
    $session = New-Object WinSCP.Session
$sessionOptions = New-Object WinSCP.SessionOptions

$sessionOptions.Protocol = [WinSCP.Protocol]::ftp
$sessionOptions.HostName = "Hostname"
$sessionOptions.UserName = "User"
$sessionOptions.Password = "Passwrd"

try {
    $session.Open($sessionOptions)

    }

} catch {
    Write-Error $_
    $session.Dispose()
}

Open in new window

0
Dear expert

Please read the code below, now I would like to do this: when the property show on 'TotalRecovered' I would CSS to change the color of that column header to green background.
Is there a way to do?

Thanks again

$credential = Import-CliXml -Path 'C:\test\cred.xml'
$attachment = 'C:\test\corona.html'
$smtp = 'smtp.office365.com'
$url = "https://www.worldometers.info/coronavirus/#countries"
$countries = 'Sweden', 'China', 'Iran','USA', 'Italy', 'Finland', 'Norway', 'Denmark', 'Russia'
# Available properties: 'Country,Other', 'TotalCases', 'NewCases', 'TotalDeaths', 'NewDeaths', 'TotalRecovered', 'ActiveCases', 'Serious,Critical', 'Tot Cases/1M pop'
$properties = 'Country,Other', 'TotalCases', 'Tot Cases/1M pop', 'TotalDeaths' , 'TotalRecovered'

$htmlHead = @' 
<style>
	BODY {background-color:white;font-family:verdana;font-size:12px;} 
	TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;} 
	TH {border-width: 1px;padding: 0px;border-style: solid;border-color: black;padding:3px;background-color:#FF0000} 
	TD {border-width: 1px;padding: 0px;border-style: solid;border-color: black;padding:3px} 
	tr:nth-child(odd) {background-color:#d3d3d3;} 
	tr:nth-child(even) {background-color:white;} 
</style>
'@

Add-Type -Path C:\Test\HtmlAgilityPack.dll
$web = New-Object -TypeName HtmlAgilityPack.HtmlWeb
$doc = $web.Load($url)
$header = $doc.DocumentNode.SelectNodes('//th') | Select-Object -ExpandProperty InnerText | 

Open in new window

0
Dear expert, I could make the code work as I wanted. Now the below script, if I run it in powershell as a not saved operation just open the powershell ISE and copy it to a untitle powershell window and run, this work perfectly, the output also works, however when I save this as a name: like corona.ps1 and put this in a task schedule plan, this is not showing correct the css seems not applied when I did it, I wonder why?

Thx

$credential = Import-CliXml -Path 'C:\test\cred.xml'
$attachment = 'C:\test\corona.html'
$htmlout = @()
$smtp = 'smtp.office365.com'
$url = "https://www.worldometers.info/coronavirus/#countries"
$countries = 'Sweden', 'China', 'Iran','USA', 'Italy', 'Finland', 'Norway', 'Denmark', 'Russia', 'Country,Other', 'TotalCases', 'NewCases', 'TotalDeaths', 'NewDeaths', 'TotalRecovered', 'ActiveCases', 'Serious,Critical', 'Tot Cases/1M pop'
$properties = 'Country,Other', 'TotalCases', 'Tot Cases/1M pop', 'TotalDeaths'
Add-Type -Path C:\Test\HtmlAgilityPack.dll
$web = New-Object -TypeName HtmlAgilityPack.HtmlWeb
$doc = $web.Load($url)
$header = $doc.DocumentNode.SelectNodes('//th') | Select-Object -ExpandProperty InnerText | ForEach-Object {($_ -replace '&nbsp;', ' ').Trim()}
$htmlout = $doc.DocumentNode.SelectNodes('//tr') | Select-Object -Skip 1 | 
ForEach-Object { $i = 0 
$out = [ordered]@{} 
$_.SelectNodes('td') | ForEach-Object { $out[$header[$i++]] = $_.InnerText.Trim() } 
$htmlHead = 
@' 
<style> 
BODY 

Open in new window

0
Dear experts

I would like to use powershell to grab a string from a txt file. The txt file got content: ........</td> <td style="font-weight: bold; text-align:right">........
I would like to first you find the </td> <td style="font-weight: bold; text-align:right"> when you find it you grab the string from the right side position of it, and 10 position to the right from the string.

The whole code below as you can see the substring(0,6) and substring(0,3) is wrong, I could however point to the txt file current position, like: 134455 or something, but that didn't work if the site change the position of the table rows.

Any idea? Thanks  

$FileName = "C:\test\world.txt"
if (Test-Path $FileName) {
  Remove-Item $FileName
}

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$corona = Invoke-WebRequest -Uri "https://www.worldometers.info/coronavirus/#countries" -UseBasicParsing
$corona.RawContent | Out-File $FileName

$sweden = 'Sweden </td> <td style="font-weight: bold; text-align:right">'
$china = 'China</a> </td> <td style="font-weight: bold; text-align:right">'

$getcontent = Get-Content $FileName | select $china

$chinainfection = $getcontent.Substring(0,6)
$chinainfection -replace ‘,’
$new = Get-Content $FileName | Select $sweden
$swedeninfection = $getcontent.Substring(0,3)
$swedeninfection -replace ‘,’
$chinapopulation = '1437616423'
$swedenpopulation = '10079833'
$chinacalc = $chinainfection / $chinapopulation * 100

Open in new window

0
Dear expert I couldn't figurer it out the way to set output of following script:

$result = ForEach ($path in $pathlist) {
$filelist = Get-ChildItem $path | Where-Object {!($_.PSIsContainer) -and ($_.LastWriteTime -le $7daysago) -or ($_.Name -like '*failed*')}
$count = $filelist | Measure-Object | Select-Object -ExpandProperty Count
If ($count -gt 0) {
$warning++

$out = '' | Select-Object -Property FilesCount, Folder, FileNames
$out.FilesCount = $count
$out.Folder = $path
$out.FileNames = $filelist.name
$out
}
}
$html = $html + "<style>"
$html = $html + "BODY{background-color:white;font-family:verdana;font-size:12px;}"
$html = $html + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$html = $html + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;padding:3px;background-color:#778899}"
$html = $html + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;padding:3px}"
$html = $html + "tr:nth-child(odd) { background-color:#d3d3d3;}"
$html = $html + "tr:nth-child(even) { background-color:white;}"
$html = $html + "</style>"
$htmlbody= @()
$htmlbody = $result | Select "FilesCount", “Folder", "FileNames" | convertto-html -head $html | out-file C:\temp\test2.html

Open in new window


The problem is in the FileNames column of the table, when it shows multi files in the folder, the output start to bug... In output when the files become more than one, it starts to show: System.Object[]

The output I would like to show is in that column of FileNames, list all the filenames with breaks between each names. I tried with:
$out.FileNames = $filelist.name -join "<br>" not working, I also tried: -join "#" and then did a -replace "#","<br>"on the $htmlbody. Those output in test2.html became weird... the columns are not showing as it should. Some filename jump outside column....

Please help, thnx in advance.
0
Dear expert this is part of the script:
$a = @'
<style>
	body	{background-color:white;font-family:verdana;font-size:22px;text-align:center;}
	table	{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;margin-left: auto;margin-right: auto;text-align:left;}
	th		{border-width: 1px;padding: 0px;border-style: solid;border-color: black;padding:3px;background-color:#d7d9d4}
	td		{border-width: 1px;padding: 0px;border-style: solid;border-color: black;padding:3px;vertical-align: middle;}
	tr[Critical="True"]			{background-color: Red;}
	tr[BatchEndedOK="False"]	{background-color: #FF0000;}
            tr[BatchEndedOK="NULL"]	{background-color: #FF0000;}
	td[FileMissing="True"]		{background-color: #FF0000; color: #FF0000;}
	td[FileMissing="False"]		{color: white;}
    td[BatchEndedOK="True"]	{background-color: Green; color: Green;}
</style>
'@

$htmlout = $arr |
	Select-Object -Property BatchName, TimeStamp, BatchOK, File |
	ConvertTo-Html -Head $a -PreContent "<H1>$($title)</H1><H2>$($timespan)</H2><H3>$($forbund)</H3><BR><BR>" |
	ForEach-Object {
		If ($_ -match '\A<tr><td>') {
			$xml = [xml]$_
			$xml.SelectSingleNode('/tr').SetAttribute('Critical', (-not $arr[$i].BatchOK).ToString())
                                    $xml.SelectSingleNode('/tr').SetAttribute('Critical', ($arr[$i].BatchOK).ToString())
			$xml.SelectSingleNode('/tr/td[3]').SetAttribute('BatchEndedOK', $arr[$i].BatchOK.ToString())
			

Open in new window

1
I would like to use PDFTK to rotate all ODD pages in 1.pdf
What is the command to do this?
0
I'm trying to get each line or row of output I get from a command into a seperate variable.
I'm defining a variable from this command I'm running (function listed below):
$PKGID = CM -Computername computer1 | Where-Object SuccessOrFailureCode -ne 0 | Select-Object packageid -ExpandProperty packageid
Write-output "$PKGID"

Open in new window

For example, if I only get one hit or SuccessOrFailureCode -ne 0, the output I get is:
1000
If I get two or more hits, the output can look like:
1001
1002
1003
I am then using this $PKGID variable in another function to trigger an install.
This only works when I have one hit, when I have more than one, the $PKGID variable encapsulates all of them and I cannot use.

Is there a way to get the output of each row into a seperate variable?  Example:
$PKGID would = 1000
$PKGID1 would = 1001
$PKGID2 would = 1002

This is the function I'm calling this from:

Function CM {

[CmdletBinding()]
Param
(
      [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true,ValueFromPipeline=$true)]
[string[]]$ComputerName = $env:COMPUTERNAME
)

Begin
{

$Code = {
# Get Execution History from registry, and package details from WMI
$ExecutionHistoryKey = "HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Software     Distribution\Execution History" 
$ContextKeys = Get-ChildItem $ExecutionHistoryKey | Select -ExpandProperty PSChildName
foreach ($ContextKey in $ContextKeys)
{
    If ($ContextKey -eq "System")
    {
        $ContextKey = 

Open in new window

0
Please assist.

In the $dc variable. If I have a single name in $DC variable the scripts works fine but if I have more than one name in the variable  $DC's  the script does not execute.

I want the $computers variable to ping $dc variable and if any one of the DCs is reachable execute the script.  Below is the script



$dc = Get-Content ".\dc.txt"
$computers = Get-Content ".\names.txt"
$Registrypol = "\\{0}\C$\Windows\System32\gp\*.txt"
$commentcmtx = "\\{0}\C$\Windows\System32\gp\mp\*.txt"
$Softwaredistribution = "\\{0}\C$\Windows\SoftwareDistributiontest"
$logfile = "\\HAZ-CM\temp\offline.txt"

Add-Content $logfile $(Get-Date)
Add-Content $logfile "Computer is Offline"
foreach ($computer in $computers) {
      Test-Connection -Source $computer -ComputerName $dc -Count 2 -ErrorAction SilentlyContinue
      If ($?) {
            Add-Content $logfile "$computer is Online"
            "$computer" >> $logfile
            Get-Service -Name wuauserv -ComputerName $computer| Stop-Service -Force
            $path = $Registrypol -f $computer
            Remove-Item -Path $path -Force
            $path = $commentcmtx -f $computer
            Remove-Item -Path $path -Force
            $path = $Softwaredistribution -f $computer
            If (Test-Path -Path $path) {
                  Remove-Item -Path $path -Recurse -Force
            }
            Get-Service -Name wuauserv -ComputerName $computer| Start-Service
            Invoke-WmiMethod -Namespace root\ccm -Class

Open in new window

1
I would like to modify this Powershell script so that it password protects the zip file.
For testing we can use the Password:   p#1234!



$7zipPath = "$env:ProgramFiles\7-Zip\7z.exe"

if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
    throw "7 zip file '$7zipPath' not found"
}

Set-Alias 7zip $7zipPath

$Source = "c:\BackupFrom\backMeUp.txt"
$Target = "c:\BackupFolder\backup.zip"

7zip a -mx=9 $Target $Source
0
Hi all,

I created a batch script and was wondering if someone could let me know if there are any syntax errors before I deploy this out.   Currently we have a customer that needs to have a directory purged nightly.   Reason is when the come in the next day their application still shows previous days data which mixes up with their current data the next day.   Here is the batch script I wrote.  Appreciate the help as always.

echo deleting file

del "D:\CZM-HFA2i\EM\Data_Export\Processed *.*" /s /f /q
del "D:\CZM-HFA2i\NM\Data_Export\Processed *.*" /s /f /q
del "D:\CZM-HFA2i\OP\Data_Export\Processed *.*" /s /f /q
del "D:\CZM-HFA2i\WM\Data_Export\Processed *.*" /s /f /q


echo Done!
0

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.