{"id":22405644,"url":"https://github.com/alecgn/usefull-powershell-scripts","last_synced_at":"2025-03-27T01:25:39.184Z","repository":{"id":261330521,"uuid":"183111272","full_name":"alecgn/usefull-powershell-scripts","owner":"alecgn","description":"A collection of usefull windows powershell scripts for Web and SQL server management.","archived":false,"fork":false,"pushed_at":"2019-04-30T23:04:29.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T07:16:00.526Z","etag":null,"topics":["backup","certificate","iis","pfx","powershell","site","sql","utils"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alecgn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-23T23:37:22.000Z","updated_at":"2023-09-07T23:54:43.000Z","dependencies_parsed_at":"2024-11-06T00:39:20.394Z","dependency_job_id":"830e7b5f-3db1-4131-98d0-f62d2c8b15e9","html_url":"https://github.com/alecgn/usefull-powershell-scripts","commit_stats":null,"previous_names":["alecgn/usefull-powershell-scripts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecgn%2Fusefull-powershell-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecgn%2Fusefull-powershell-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecgn%2Fusefull-powershell-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecgn%2Fusefull-powershell-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecgn","download_url":"https://codeload.github.com/alecgn/usefull-powershell-scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245762493,"owners_count":20668090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","certificate","iis","pfx","powershell","site","sql","utils"],"created_at":"2024-12-05T10:24:30.087Z","updated_at":"2025-03-27T01:25:39.150Z","avatar_url":"https://github.com/alecgn.png","language":"PowerShell","readme":"# usefull-powershell-scripts\nA collection of usefull Windows Powershell scripts for Windows Server administrative tasks.\n\n--------------------------------------------------\n\n## backup-directory.ps1\n### A Windows Powershell script to backup an entire folder to another, with compression support (no need for third-party compression programs).\n\n**Usage examples:**\n\u003e**PS C:\\scripts\\\u003e .\\backup-directory.ps1 -Source C:\\inetpub\\wwwroot -Destination D:\\backups -CreateDateMaskDirectory -Zip**  \n\n\u003e**PS C:\\scripts\\\u003e .\\backup-directory.ps1 -Source C:\\inetpub\\wwwroot -Destination \\\\\\\\server\\backups -CreateDateMaskDirectory -Zip**\n\n**Parameters:**\n\n**-Source**: Mandatory. The source directory to backup.  \n**-Destination**: Mandatory. The destination directory where the source or compressed source directory will be backedup.  \n**-CreateDateMaskDirectory**: Optional. In the destination directory, creates a folder with the current date mask (yyyy-DD-mm -\u003e eg \"2019-04-23\") then place the source or compressed source directory there; if not supplied, just copy the source directory to the destination.  \n**-Zip**: Optional. Compress the source directory to a .zip file in the destination directory, named with the same name of the source directory; if not supplied, just copy the source directory without compress it.\n\nBefore running the script, set the execution police to **RemoteSigned** or **Unrestricted** to allow scripts execution:  \n\u003e**PS C:\\scripts\\\u003e Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine**\n\n--------------------------------------------------\n\n## iis-config-backup.ps1\n### A Windows Powershell script to backup IIS configuration.\n\n**Usage example:**\n\u003e**PS C:\\scripts\\\u003e .\\iis-config-backup.ps1 -DestinationDirectory D:\\backups -CreateDateMaskDirectory -Zip**  \n\n**Parameters:**\n\n**-DestinationDirectory**: Mandatory. The destination directory where the IIS configuration files will be backedup.  \n**-CreateDateMaskDirectory**: Optional. In the destination directory, creates a folder with the current date mask (yyyy-DD-mm -\u003e eg \"2019-04-23\") then place the IIS configuration files there; if not supplied, just copy configuration files to the destination.  \n**-Zip**: Optional. Compress the IIS configuration files to a .zip file in the destination directory; if not supplied, just copy configuration files without compress them.  \n\nBefore running the script, set the execution police to **RemoteSigned** or **Unrestricted** to allow scripts execution:  \n\u003e**PS C:\\scripts\\\u003e Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine**\n\n--------------------------------------------------\n\n## pfxcert-export.ps1\n### A Windows Powershell script to backup a single certificate or an entire certificate store.\n\n**Usage examples:**\n\u003e**PS C:\\scripts\\\u003e .\\pfxcert-export.ps1 -CertPath Cert:\\LocalMachine\\My\\ACB239B3689E4EF8CBAF65FA7A91BE8EDAFA7D35 -DestinationDirectory D:\\backups -PfxFileName mysinglecert.pfx -Password cert123 -CreateDateMaskDirectory**  \n\n\u003e**PS C:\\scripts\\\u003e .\\pfxcert-export.ps1 -CertPath Cert:\\LocalMachine\\My -DestinationDirectory D:\\backups -PfxFileName myallcerts.pfx -Password cert123 -CreateDateMaskDirectory**\n\n**Parameters:**\n\n**-CertPath**: Mandatory. The source certificate/store path to backup.  \n**-DestinationDirectory**: Mandatory. The destination directory where the .pfx file of certificate/store will be backedup.  \n**-PfxFileName**: Mandatory. The .pfx output file name.  \n**-Password**: Mandatory. The .pfx file password.  \n**-CreateDateMaskDirectory**: Optional. In the destination directory, creates a folder with the current date mask (yyyy-DD-mm -\u003e eg \"2019-04-23\") then place the .pfx file there; if not supplied, just create the .pfx file in the destination directory.  \n\nBefore running the script, set the execution police to **RemoteSigned** or **Unrestricted** to allow scripts execution:  \n\u003e**PS C:\\scripts\\\u003e Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine**  \n\nTo get the fingerprints of all certificates from a store, run a command like the following, passing the store path:  \n\u003e**PS C:\\scripts\\\u003e Get-ChildItem -Path Cert:\\LocalMachine\\WebHosting**  \n\n***Note that the certificate(s) key(s) must be exportable for this script to work.**\n\n--------------------------------------------------\n\n## sql-backup.ps1\n### A Windows Powershell script to backup all databases from a SQL Server instance.\n\n**Usage examples:**\n\u003e**PS C:\\scripts\\\u003e .\\sql-backup.ps1 -SQLInstance $env:computername\\Default -DestinationDirectory C:\\backups -CreateDateMaskDirectory**  \n\n\u003e**PS C:\\scripts\\\u003e .\\sql-backup.ps1 -SQLInstance SRV-SQL\\MSSQLSERVER -DestinationDirectory \\\\\\\\REMOTE-SHARE\\backup-sql -CreateDateMaskDirectory**\n\n**Parameters:**\n\n**-SQLInstance**: Mandatory. Instance connection in the format \"COMPUTER_NAME\\INSTANCE_NAME\"; \"$env:computername\\Default\" does the trick for backingup a single default instance in the same machine.  \n**-DestinationDirectory**: Mandatory. The destination directory where the .bak backup files will be backedup.  \n**-CreateDateMaskDirectory**: Optional. In the destination directory, creates a folder with the current date mask (yyyy-DD-mm -\u003e eg \"2019-04-23\") then place the .bak backup files there; if not supplied, just create the .bak backup files in the destination.  \n\nBefore running the script, set the execution police to **RemoteSigned** or **Unrestricted** to allow scripts execution:  \n\u003e**PS C:\\scripts\\\u003e Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine**\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecgn%2Fusefull-powershell-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecgn%2Fusefull-powershell-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecgn%2Fusefull-powershell-scripts/lists"}