powershell - 试图重命名计算机。但是脚本调用深度溢出失败
问题描述
我有一个 powershell 功能来重命名计算机。以下是脚本:
#region Download-GitRepositories
<#
.SYNOPSIS
This function will rename the computer to hardware serial number.
.EXAMPLE
Rename-Machine
#>
function Rename-Machine
{
$env:SerialNumber = "0001"
$newname = $env:SerialNumber
$oldname = $env:COMPUTERNAME
#Renamer the Computer.
$localcredential = Get-Credential
Rename-Computer –ComputerName $oldname –NewName $newname -LocalCredential $localcredential
}
当我通过运行 Rename-Machine 命令调用该函数时,它会给出错误消息:
The script failed due to call depth overflow.
+ CategoryInfo : InvalidOperation: (0:Int32) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CallDepthOverflow
我做错了什么?我似乎无法在脚本中找到任何递归调用来获取调用深度溢出错误。
解决方案
推荐阅读
- wagtail - 如何将 Wagtail 管理仪表板标题从“欢迎使用 bakerydemo Wagtail CMS”?
- angular - 如何在 ngIf 表达式中使用多个作为关键字?
- php - 在不更改源代码的情况下扩展程序。坚实的 PHP OOP
- google-apps-script - 从 Google Apps 脚本更新 Salesforce 记录
- neural-network - Caffe CNN:用于分层分类的多个分层损失
- complexity-theory - BigInteger 连续方法的复杂度如何计算?
- java - 如何将查询传递给 FirestoreRecyclerOptions?
- php - 从两列建议自动完成的Mysql查询?
- javascript - 函数中的条件选择
- javascript - 如何在父页面上打开 ChildPage 的模态弹出窗口?