< Back
Save-HFMHostFile
Post
NAME Save-HFMHostFile
SYNOPSIS
Backup Hosts File.
SYNTAX
Save-HFMHostFile [-Path] <HostsFile[]> [[-BackupFolder] <DirectoryInfo>] [[-MaxLogRotation] <Int32>]
[<CommonParameters>]
DESCRIPTION
Backup Hosts File. By default the backup file will be stored in the system32\\drivers\\etc folder.
You can use the BackupFolder to specify override the default behavior of the cmdlet.
Hosts file backups are prefixed with a timestamp, and the name of the current computer.
20181010-185510_COMPUTER1_Hosts.Bak
PARAMETERS
-Path <HostsFile[]>
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-BackupFolder <DirectoryInfo>
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-MaxLogRotation <Int32>
Required? false
Position? 3
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
Input must be of type [HostsFile].
OUTPUTS
File, extension .bak
NOTES
Remember to run Powershell in elevated mode, if you must backup your current hosts file by using the
following: Get-FHMHostsFile | Save-HFMHostFile
Standard credential dont allow you to write inside the system32\\drivers\\etc folder.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$a = Get-FHMHostsFile
PS C:\\> Save-HFMHostsFile -Path $a
Creates a backup of your hosts file.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-FHMHostsFile | Save-HFMHostFile -BackupFolder c:\\temp
Create a backup of your hosts file in the c:\\temp folder. MaxLog
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>"Computer1","Computer2" | Get-FHMHostsFile | Save-HFMHostsFile -BackupFolder c:\\temp -MaxLogRotation 10
Creates a backup of the named computer hosts files, in your c:\\temp folder. Each computer can have a max of 10
.bak files.
RELATED LINKS
SYNOPSIS
Backup Hosts File.
SYNTAX
Save-HFMHostFile [-Path] <HostsFile[]> [[-BackupFolder] <DirectoryInfo>] [[-MaxLogRotation] <Int32>]
[<CommonParameters>]
DESCRIPTION
Backup Hosts File. By default the backup file will be stored in the system32\\drivers\\etc folder.
You can use the BackupFolder to specify override the default behavior of the cmdlet.
Hosts file backups are prefixed with a timestamp, and the name of the current computer.
20181010-185510_COMPUTER1_Hosts.Bak
PARAMETERS
-Path <HostsFile[]>
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-BackupFolder <DirectoryInfo>
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-MaxLogRotation <Int32>
Required? false
Position? 3
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
Input must be of type [HostsFile].
OUTPUTS
File, extension .bak
NOTES
Remember to run Powershell in elevated mode, if you must backup your current hosts file by using the
following: Get-FHMHostsFile | Save-HFMHostFile
Standard credential dont allow you to write inside the system32\\drivers\\etc folder.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$a = Get-FHMHostsFile
PS C:\\> Save-HFMHostsFile -Path $a
Creates a backup of your hosts file.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-FHMHostsFile | Save-HFMHostFile -BackupFolder c:\\temp
Create a backup of your hosts file in the c:\\temp folder. MaxLog
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>"Computer1","Computer2" | Get-FHMHostsFile | Save-HFMHostsFile -BackupFolder c:\\temp -MaxLogRotation 10
Creates a backup of the named computer hosts files, in your c:\\temp folder. Each computer can have a max of 10
.bak files.
RELATED LINKS