About Functions
这个坑,浪费我一天时间,才填上,蛋疼
先上错误代码:
#函数
function Write-Ini ($IniKey, $Value)
{
$Section = "关机";
$FilePath = "$PSScriptRoot\Site.ini";
$Null = [IniFileManager]::WriteToIniFile($FilePath, $Section, $IniKey, $Value);
};
#调用
Write-Ini ( "DownloadSpeed", $dlShutdown);
玩了这么多的鹰,自认为这样写没毛病,可惜他狠狠的啄了我一脸,ini 输出为:
[关机]
DownloadSpeed 600=
然后就疯狂改代码,疯狂找资料,各种吐血行为,差点想自编一个算了,最后认认真真拜读微软文档后,才发现我调用出错了
修改后:
function Write-Ini
{
param ([string]$IniKey, [string]$Value);
$Section = "关机";
$FilePath = "$PSScriptRoot\Site.ini";
$Null = [IniFileManager]::WriteToIniFile($FilePath, $Section, $IniKey, $Value);
};
Write-Ini -IniKey "DownloadSpeed" -Value $dlShutdown;
撒花完结,睡觉了(两天一夜没闭眼了)