[CmdletBinding()] param( [string]$Name = 'Имя Фамилия', [string]$Title = 'Должность', [string]$Email = 'user@example.com', [string]$Phone = '+1 555 0100', [string]$Site = 'https://example.com', [string]$Output = 'business-card.html', [switch]$Force ) $ErrorActionPreference = 'Stop' $target = $Output if (Test-Path -LiteralPath $target) { if (-not $Force) { throw "Файл уже существует: $target. Добавьте -Force для замены." } } $template = @' {{NAME}}

{{NAME}}

{{TITLE}}
Почта{{EMAIL}}
Телефон{{PHONE}}
Сайт{{SITE}}
'@ function ConvertTo-HtmlText { param([string]$Value) return [System.Net.WebUtility]::HtmlEncode($Value) } $html = $template.Replace('{{NAME}}', (ConvertTo-HtmlText -Value $Name)) $html = $html.Replace('{{TITLE}}', (ConvertTo-HtmlText -Value $Title)) $html = $html.Replace('{{EMAIL}}', (ConvertTo-HtmlText -Value $Email)) $html = $html.Replace('{{PHONE}}', (ConvertTo-HtmlText -Value $Phone)) $html = $html.Replace('{{SITE}}', (ConvertTo-HtmlText -Value $Site)) $directory = Split-Path -LiteralPath $target if ($directory -and -not (Test-Path -LiteralPath $directory)) { New-Item -ItemType Directory -Path $directory -Force | Out-Null } Set-Content -LiteralPath $target -Value $html -Encoding UTF8 Write-Host "Визитка сохранена: $target"