logo
down
shadow

Compress-Archive powershell command not known in windows 7


Compress-Archive powershell command not known in windows 7

Content Index :

Compress-Archive powershell command not known in windows 7
Tag : powershell , By : vasil
Date : November 25 2020, 07:22 PM

seems to work fine Compress-Archive is only available with PS v4 onwards.
Check your powershell version using $PSVersionTable as you'll likely still be on PS v2 with Windows 7 unless you've upgraded WMF.
powershell -ExecutionPolicy unrestricted -Command "$PSVersionTable"
$PSVersionTable

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

PowerShell Compress-Archive By File Extension


Tag : powershell , By : George H.
Date : March 29 2020, 07:55 AM
I hope this helps you . I would suggest copying the files to a temporary directory and compress that. Ex:
$path = "test"
$filter = "*.config"

#To support both absolute and relative paths..
$pathitem = Get-Item -Path $path

#If sourcepath exists
if($pathitem) {
    #Get name for tempfolder
    $tempdir = Join-Path $env:temp "CompressArchiveTemp"

    #Create temp-folder
    New-Item -Path $tempdir -ItemType Directory -Force | Out-Null

    #Copy files
    Copy-Item -Path $pathitem.FullName -Destination $tempdir -Filter $filter -Recurse

    #Get items inside "rootfolder" to avoid that the rootfolde "test" is included.
    $sources = Get-ChildItem -Path (Join-Path $tempdir $pathitem.Name) | Select-Object -ExpandProperty FullName

    #Create zip from tempfolder
    Compress-Archive -Path $sources -DestinationPath config-files.zip

    #Remove temp-folder
    Remove-Item -Path $tempdir -Force -Recurse
}

Using Compress-Archive in Powershell


Tag : powershell , By : glisignoli
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I am attempting to create a zip from from a folder using powershell 5 on Windows 10. After looking at this stackoverflow post I am trying out the Compress-Archive method. , This message can appear if the folder you are compressing is empty.

Windows 10 powershell ise compress-archive files at root .in .zip


Tag : windows , By : mgaspar
Date : March 29 2020, 07:55 AM
it fixes the issue With your -Path being a folder you explicitly include it in the archive.
As already mentioned by Tomalak giving a wildcard changes that.
Compress-Archive -Path C:\wamp64\www\myFolder\* -DestinationPath C:\wamp64\www\myFolder\myZip.zip
Compress-Archive C:\wamp64\www\myFolder\* C:\wamp64\www\myFolder\myZip.zip
Get-ChildItem C:\wamp64\www\myFolder\* -File | Compress-Archive C:\wamp64\www\myFolder\myZip.zip

Exclude sub-directories from Compress-Archive Powershell Cmd


Tag : powershell , By : Erik
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I apologize in advance if this question seems odd, this is my first time trying to use powershell for anything like this. , Here's a possible option (what i meant by my comment)
$entries = New-Object System.Collections.Generic.List[System.Object] 

$exclude = "DIR2,DIR6"

# Get initial directory listing
$dirlist = Get-ChildItem $solutionFileLocation -ad -Exclude "$exclude" | ForEach-Object { $_.FullName }

# Exclude bin and obj directories and add entry path to our zip entry list
foreach ($dir in $dirlist)
{
    $sub = Get-ChildItem $dir -Exclude "bin", "obj" | ForEach-Object { $_.FullName }

    $entries.Add("$($dir.split('/')[-1])/")
    foreach ($itm in $sub)
    {
        $entries.Add($itm)
    }
}

Compress-Archive -LiteralPath $entries -CompressionLevel Optimal -DestinationPath "C:\Filename01212019.zip"

How can I loop through specific file names with the Compress-Archive command in Windows PowerShell?


Tag : powershell , By : Arun Thomas
Date : March 29 2020, 07:55 AM
wish helps you I am not too familiar with Windows PowerShell (and Windows console commands in general), but I wish to write a batch file which can create sperated .zip archives from specific files in a folder, then delete all but the .zip files. So, I have a folder as "C:\myfolder\" and some files in it like: myfile0001.a myfile0001.b myfile0001.c myfile0002.a myfile0002.b myfile0002.c myfile0003.a myfile0003.b myfile0003.c ... and so on. , In PowerShell, you could do:
Get-ChildItem -Path 'C:\myfolder' -File | Where-Object { $_.BaseName -match 'myfile\d{4}' } | Group-Object BaseName | ForEach-Object {
    $target = Join-Path -Path ($_.Group[0].DirectoryName) -ChildPath ('{0}.zip' -f $_.Group[0].BaseName)
    $_.Group | Compress-Archive -CompressionLevel Optimal -DestinationPath $target
    $_.Group | Remove-Item -Force
}
powershell -Command "& {Get-ChildItem -Path 'C:\myfolder' -File | Where-Object { $_.BaseName -match 'myfile\d{4}' } | Group-Object BaseName | ForEach-Object { $target = Join-Path -Path ($_.Group[0].DirectoryName) -ChildPath ('{0}.zip' -f $_.Group[0].BaseName); $_.Group | Compress-Archive -CompressionLevel Optimal -DestinationPath $target; $_.Group | Remove-Item -Force}}"
Related Posts Related QUESTIONS :
  • Read CSV file then split the values and create a global variable
  • (Get-Date).ToUniversalTime() convert to string but not change format
  • Adding Extra Headers in CSV
  • New-Mailbox command does not accept the -Equipment argument
  • How do I remove IIS 'server' header from http response using Powershell?
  • Creating Subdirectory With Date As Today(mm-dd-yyyy) in Network Drive
  • My first parameter is not being passed to my function
  • How can I overwrite an existing zip file?
  • How to use double if statement using powershell?
  • Command using either or both -Path parameter and $input?
  • How can I return multiple values from a powershell script to the batch file that is calling it?
  • Sensitive word search with powershell
  • Copy files located in multiple subfolder, using a mildmatch search
  • Replace the text for all files in a Directory
  • How to write a PowerShell script which auto increments a number by 1 every time it's run?
  • new user powershell get-service
  • Removing Parts of a File Name based on a Delimiter
  • How can we transform Date in CSV file using PowerShell scripts
  • How to replace multiple characters (<3) of all the filenames in a folder (and subfolder) using PowerShell
  • Powershell environment variable
  • Removing spaces from a string using Powershell
  • List Filename and current date of all files in a directory
  • PowerShell calling environment variable with another variable
  • Uninstall all software starting with a specific string
  • Set-ADUser does not handle empty or null variables
  • How do I get the data results from Invoke-RestMethod into CSV file?
  • ConvertFrom-String returns symbol not text
  • Get-WinEvent Select time and field within data item of 1
  • Create multiple files with Powershell?
  • I have a folder that contains multiple folders which contain images. I want to filter the images based on dimensions
  • Function not working even though variable looks fine
  • How to specify multiple files in $sourcePath
  • Deleting a specific tag in xml file
  • Suppressing called function/cmdlet's WhatIf output, when that function has no WhatIf parameter
  • Import CSV File to a new Excel Worksheet within an existing Excel Workbook
  • Start-Service cmdlet: get underlying error in case of failure
  • What would the opposite if this office 365 powershell command?
  • How to install the WASP in powershell?
  • change powershell command color
  • How to list all installed, runnable cmdlets in powershell?
  • PowerShell index value of PSObject
  • Powershell Foreach-Object behaves abnormaly on null values
  • My code will not write "No files to process"
  • Get certificates information using powershell
  • How to uninstall dell support assist with powershell?
  • EF6 Add-Migration in PowerShell, outside Visual Studio
  • Not able to rename button base on value
  • Description property dont give back result
  • Using powershell script with different parameters
  • How to get the current script to read off computer names off a txt file located on c:\
  • Powershell check if drive letter exists and if so remove
  • Powershell script to return search results from a list of keywords
  • PowerShell copy fails without warning
  • Get Windows Last Reboot Timestamp?
  • In PowerShell how to capture error, warning, write-host output into a single file?
  • Set-Acl only on on files containing certain keyword
  • Weird Coalesce Behavior
  • Search for a word within a file that has a specific modified date
  • How to fetch first column from given powershell array?
  • How to add text to a file foreach column using PowerShell?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com