跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 必须马克, PowerShell function 太坑了
未分類
21 5 月 2020

必须马克, PowerShell function 太坑了

必须马克, PowerShell function 太坑了

資深大佬 : sx90 46

About Functions

这个坑,浪费我一天时间,才填上,蛋疼

先上错误代码:

#函数 function Write-Ini  ($IniKey, $Value) {  $Section = "关机";  $FilePath = "$PSScriptRootSite.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 = "$PSScriptRootSite.ini";   $Null = [IniFileManager]::WriteToIniFile($FilePath, $Section, $IniKey, $Value);  };  Write-Ini -IniKey "DownloadSpeed" -Value $dlShutdown; 

撒花完结,睡觉了(两天一夜没闭眼了)

大佬有話說 (0)

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具