Home
%3CLINGO-SUB%20id%3D%22lingo-sub-713344%22%20slang%3D%22en-US%22%3ETQA%3A%20Add-ClusterVirtualMachineRole%20fails%20with%20the%20error%20%22The%20File%20Exists%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-713344%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20time%20I%20was%20involved%20to%20identify%20a%20problem%20that%20stuck%20all%20the%20DR%20tests%20in%20a%20large%20enterprise%2C%20let%20me%20show%20you%20a%20description%20of%20the%20environment.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23000000%22%3E%3CSTRONG%3EENVIRONMENT%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20995px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120040iCB6E863409239629%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Environment.png%22%20title%3D%22Environment.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EThe%20Customer%20have%20a%20Production%20%3CSTRONG%3EHyper-V%20Farm%3C%2FSTRONG%3E%20(multiple%20HV%20clusters)%20on%20a%20%3CSTRONG%3EPrimary%20Datacenter%3C%2FSTRONG%3E%2C%20this%20farm%20have%20multiple%20%3CSTRONG%3ELUNs%3C%2FSTRONG%3E%20(Logical%20Unit%20Number)%20on%20a%20Storage%20visible%20to%20the%20hosts%20via%20%3CSTRONG%3EFC%3C%2FSTRONG%3E%20(Fiber%20Channel).%20The%20storage%20replicate%20the%20LUNs%20with%20an%20%3CSTRONG%3Easynchronous%20replica%3C%2FSTRONG%3E%20to%20the%20%3CSTRONG%3EDR%3C%2FSTRONG%3E%20(Disaster%20Recovery)%20datacenter.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EThe%20customer%2C%20during%20the%20year%2C%20make%20multiple%20simulation%20on%20the%20%3CSTRONG%3EDR%20datacenter%3C%2FSTRONG%3E%3CFONT%20size%3D%223%22%3E%20to%20validate%20if%20the%20DR%20work%20correctly%2C%20but%20in%20the%20last%20simulation%20the%20%3CSTRONG%3EOrchestrator%20server%3C%2FSTRONG%3E%20in%20the%20DR%20datacenter%20stopped%20the%20execution%20of%20the%20runbooks%2C%20that%20automate%20the%20import%20of%20the%20VMs%20from%20the%20LUNs%2C%20with%20the%20following%20error%20message%3A%3C%2FFONT%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%20color%3D%22%23ff0000%22%3E%22Add-ClusterVirtualMachineRole%20%3A%20The%20File%20exists.%22%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CFONT%20color%3D%22%23000000%22%3E%3CSTRONG%3ETROUBLESHOOTING%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%223%22%3EWe%20identified%20inside%20of%20the%20orchestrator%20runbooks%20the%20piece%20of%20code%20that%20generate%20the%20exception%20and%20we%20retried%20the%20execution%20of%20the%20cmdlet%20only%20on%20a%20single%20VM%20like%20in%20this%20case%3A%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120083i9EE7F9142F5E61E2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22error.png%22%20title%3D%22error.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWe%20start%20thinking%20that%20may%20be%20the%20VM%20was%20already%20present%20in%20the%20Hyper-V%20cluster%2C%20but%20why%20we%20receive%20the%20message%20%3CSTRONG%3E%22The%20File%20Exists%22!%3C%2FSTRONG%3E%20So%20we%20have%20retried%20the%20command%20with%20the%20%3CSTRONG%3E%22-verbose%22%26nbsp%3B%3C%2FSTRONG%3Eparameter%2C%20and%20we%20received%20this%20additional%20info%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120082iD2CFCB31BCF31ACC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22error_verbose.png%22%20title%3D%22error_verbose.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFrom%20this%20info%2C%20it%20seams%20that%20the%20cmdlet%20%22%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Ffailoverclusters%2Fadd-clustervirtualmachinerole%3Fview%3Dwin10-ps%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAdd-ClusterVirtualMachineRole%3C%2FA%3E%22%20(that%20add%20the%20VM%20to%20the%20Hyper-V%20cluster)%20is%20trying%20to%20get%20a%20temporary%20file%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20size%3D%221%22%20color%3D%22%23000000%22%3E%3CFONT%20face%3D%22Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%22%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EVERBOSE%3A%20Connecting%20to%20cluster%20on%20local%20computer%20HV1-2016.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%22%20color%3D%22%23000000%22%3E%3CFONT%20face%3D%22Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%22%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EVERBOSE%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CFONT%20color%3D%22%23000000%22%3Eat%20%3C%2FFONT%3E%3CSTRONG%3E%3CFONT%20color%3D%22%23ff0000%22%3ESystem.IO.__Error.WinIOError%3C%2FFONT%3E%3C%2FSTRONG%3E(Int32%20errorCode%2C%20String%20maybeFullPath)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20at%3CSTRONG%3E%3CFONT%20color%3D%22%23ff0000%22%3E%20System.IO.Path.InternalGetTempFileName%3C%2FFONT%3E%3C%2FSTRONG%3E(Boolean%20checkHost)%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3ESo%20we%20downloaded%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsysinternals%2Fdownloads%2Fprocmon%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EProcess%20Monitor%3C%2FA%3E%20and%20we%20retried%26nbsp%3B%3CA%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23146cac%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20underline%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Ffailoverclusters%2Fadd-clustervirtualmachinerole%3Fview%3Dwin10-ps%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAdd-ClusterVirtualMachineRole%3C%2FA%3E%20for%20a%20single%20VM%20and%20we%20noticed%20these%20events%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120105i60382F32B40DBF5C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22procmon.png%22%20title%3D%22procmon.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EDuring%20the%20execution%20of%20the%20cmdlet%20we%20saw%20that%20the%20PowerShell%20try%20to%20create%20multiple%20TMP%20files%20like%20%22%3CSTRONG%3Etmp2C0E.tmp%3C%2FSTRONG%3E%22%20but%20it%20fail%20with%20a%20%22%3CSTRONG%3ENAME%20COLLISION%3C%2FSTRONG%3E%22%20message.%20%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3ESo%20we%20start%20to%20investigate%20on%20the%20method%20used%20by%20this%20cmdlet%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%3CFONT%20face%3D%22Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%22%20style%3D%22background-color%3A%20%23ffffff%3B%22%20color%3D%22%23b00000%22%3E%3CSTRONG%3E%3CFONT%20color%3D%22%23000000%22%3ESystem.IO%3CFONT%20color%3D%22%23ff0000%22%3E.%3C%2FFONT%3E%3C%2FFONT%3E%3CFONT%20color%3D%22%23ff0000%22%3EPath.InternalGetTempFileName%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23000000%22%3E%3CSTRONG%3ESOLUTION%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EReading%20the%20documentation%20of%20the%20method%20used%20by%20the%20cmdlet%2C%20we%20identified%20the%20root%20cause%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%20class%3D%22x-hidden-focus%22%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EThis%20method%20creates%20a%20temporary%20file%20with%20a%20.TMP%20file%20extension.%20%3CFONT%20color%3D%22%23ff0000%22%3EThe%20temporary%20file%20is%20created%20within%20the%20user's%20temporary%20folder%2C%3C%2FFONT%3E%20which%20is%20the%20path%20returned%20by%20the%20%3CA%20class%3D%22xref%22%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20inherit%3B%20color%3A%20var(--primary-base)%3B%20cursor%3A%20pointer%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20overflow-wrap%3A%20break-word%3B%20text-decoration%3A%20underline%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.io.path.gettemppath%3Fview%3Dnetframework-4.8%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20data-linktype%3D%22relative-path%22%3EGetTempPath%3C%2FA%3E%20method.%3C%2FP%3E%0A%3CP%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CFONT%20color%3D%22%23ff0000%22%3EThe%20%3CA%20class%3D%22xref%22%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20inherit%3B%20color%3A%20var(--primary-base)%3B%20cursor%3A%20pointer%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20overflow-wrap%3A%20break-word%3B%20text-decoration%3A%20underline%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.io.path.gettempfilename%3Fview%3Dnetframework-4.8%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20data-linktype%3D%22relative-path%22%3EGetTempFileName%3C%2FA%3E%20method%20will%20raise%20an%20%3CA%20class%3D%22xref%22%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20inherit%3B%20color%3A%20var(--primary-base)%3B%20cursor%3A%20pointer%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20overflow-wrap%3A%20break-word%3B%20text-decoration%3A%20underline%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.io.ioexception%3Fview%3Dnetframework-4.8%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20data-linktype%3D%22relative-path%22%3EIOException%3C%2FA%3E%20if%20it%20is%20used%20to%20create%20more%20than%20%3CSTRONG%3E65535%3C%2FSTRONG%3E%3C%2FFONT%3E%20files%20without%20deleting%20previous%20temporary%20files.%3C%2FP%3E%0A%3CP%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EThe%20%3CA%20class%3D%22xref%22%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20inherit%3B%20color%3A%20var(--primary-base)%3B%20cursor%3A%20pointer%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20overflow-wrap%3A%20break-word%3B%20text-decoration%3A%20underline%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.io.path.gettempfilename%3Fview%3Dnetframework-4.8%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20data-linktype%3D%22relative-path%22%3EGetTempFileName%3C%2FA%3E%20method%20will%20raise%20an%20%3CA%20class%3D%22xref%22%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20inherit%3B%20color%3A%20var(--primary-base)%3B%20cursor%3A%20pointer%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20overflow-wrap%3A%20break-word%3B%20text-decoration%3A%20underline%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.io.ioexception%3Fview%3Dnetframework-4.8%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20data-linktype%3D%22relative-path%22%3EIOException%3C%2FA%3E%20if%20no%20unique%20temporary%20file%20name%20is%20available.%20%3CFONT%20color%3D%22%23ff0000%22%3ETo%20resolve%20this%20error%2C%20delete%20all%20unneeded%20temporary%20files.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CFONT%20color%3D%22%23000000%22%3E%3CSTRONG%3EOfficial%20Reference%20available%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.io.path.gettempfilename%3Fview%3Dnetframework-4.8%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere.%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CFONT%20color%3D%22%23000000%22%3EBecause%20the%20customer%20during%20the%20year%20have%20made%20multiple%20tests%20on%20the%20DR%20environment%2C%20the%20Orchestrator%20user%20that%20start%20the%20runbooks%20had%20more%20than%3CSTRONG%3E%2065535%20%3C%2FSTRONG%3Etemporary%20files%20in%20the%20temp%20user%20folder%20with%20this%20kind%20of%20syntax%20%3CSTRONG%3E%22%3C%2FSTRONG%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20font-weight%3A%20bold%3B%22%3EtmpXXXX.tmp%22%3C%2FSTRONG%3E%3C%2FFONT%3E.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CFONT%20color%3D%22%23000000%22%3EThe%20final%20solution%20was%20to%20add%20few%20line%20of%20code%20at%20the%20beginning%20of%20the%20runbook%20on%20the%20orchestrator%20server%20to%20%3CSTRONG%3Ecleanup%20the%20temp%20folder%20of%20the%20orchestrator%20user%3C%2FSTRONG%3E.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CFONT%20size%3D%224%22%20color%3D%22%23000000%22%3E%3CSTRONG%3ENICE%20TO%20KNOW%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22box-sizing%3A%20inherit%3B%20color%3A%20%23000000%3B%20font-family%3A%20Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20margin-bottom%3A%200px%3B%20margin-top%3A%201rem%3B%20orphans%3A%202%3B%20overflow-wrap%3A%20break-word%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EI%20was%20able%20to%20reproduce%20the%20Customer%20issue%20on%20a%20single%20Hyper-V%20Cluster%20in%20my%20lab%2C%20by%20using%20the%20%3CSTRONG%3E%22%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.utility%2Fnew-temporaryfile%3Fview%3Dpowershell-6%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ENew-TemporaryFile%3C%2FA%3E%22%20%3C%2FSTRONG%3Ecmdlet%2C%20because%20it%20use%20the%20same%20method%20for%20the%20creation%20of%20the%20TMP%20files.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-713344%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EThe%20Add-ClusterVirtualMachineRole%20fail%20with%20the%20error%3A%20%22The%20File%20Exist%22.%20View%20the%20troubleshooting%20steps.%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20750px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120688iBAE033A594EEDECD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Tough_Questions_Answered.png%22%20title%3D%22Tough_Questions_Answered.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ETough%20Questions%20Answered%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-713344%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-727542%22%20slang%3D%22en-US%22%3ERe%3A%20TQA%3A%20Add-ClusterVirtualMachineRole%20fails%20with%20the%20error%20%22The%20File%20Exists%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-727542%22%20slang%3D%22en-US%22%3E%3CP%3EIndeed%2C%20nice%20to%20know.%26nbsp%3B%3CBR%20%2F%3EThank%20you%20for%20the%20post.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3ERegards%2C%26nbsp%3B%3CBR%20%2F%3EAlex%3C%2FP%3E%3C%2FLINGO-BODY%3E

This time I was involved to identify a problem that stuck all the DR tests in a large enterprise, let me show you a description of the environment.

 

ENVIRONMENT

 

Environment.png

The Customer have a Production Hyper-V Farm (multiple HV clusters) on a Primary Datacenter, this farm have multiple LUNs (Logical Unit Number) on a Storage visible to the hosts via FC (Fiber Channel). The storage replicate the LUNs with an asynchronous replica to the DR (Disaster Recovery) datacenter.

The customer, during the year, make multiple simulation on the DR datacenter to validate if the DR work correctly, but in the last simulation the Orchestrator server in the DR datacenter stopped the execution of the runbooks, that automate the import of the VMs from the LUNs, with the following error message:

"Add-ClusterVirtualMachineRole : The File exists."

TROUBLESHOOTING
We identified inside of the orchestrator runbooks the piece of code that generate the exception and we retried the execution of the cmdlet only on a single VM like in this case:

error.png

We start thinking that may be the VM was already present in the Hyper-V cluster, but why we receive the message "The File Exists"! So we have retried the command with the "-verbose" parameter, and we received this additional info:

error_verbose.png

From this info, it seams that the cmdlet "Add-ClusterVirtualMachineRole" (that add the VM to the Hyper-V cluster) is trying to get a temporary file:

 

VERBOSE: Connecting to cluster on local computer HV1-2016.

VERBOSE:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Path.InternalGetTempFileName(Boolean checkHost)

So we downloaded the Process Monitor and we retried Add-ClusterVirtualMachineRole for a single VM and we noticed these events:

procmon.png

During the execution of the cmdlet we saw that the PowerShell try to create multiple TMP files like "tmp2C0E.tmp" but it fail with a "NAME COLLISION" message.

So we start to investigate on the method used by this cmdlet:

System.IO.Path.InternalGetTempFileName

SOLUTION

Reading the documentation of the method used by the cmdlet, we identified the root cause:

This method creates a temporary file with a .TMP file extension. The temporary file is created within the user's temporary folder, which is the path returned by the GetTempPath method.

The GetTempFileName method will raise an IOException if it is used to create more than 65535 files without deleting previous temporary files.

The GetTempFileName method will raise an IOException if no unique temporary file name is available. To resolve this error, delete all unneeded temporary files.

Official Reference available here.

Because the customer during the year have made multiple tests on the DR environment, the Orchestrator user that start the runbooks had more than 65535 temporary files in the temp user folder with this kind of syntax "tmpXXXX.tmp".

The final solution was to add few line of code at the beginning of the runbook on the orchestrator server to cleanup the temp folder of the orchestrator user.

NICE TO KNOW

I was able to reproduce the Customer issue on a single Hyper-V Cluster in my lab, by using the "New-TemporaryFile" cmdlet, because it use the same method for the creation of the TMP files.

1 Comment
Established Member

Indeed, nice to know. 
Thank you for the post. 

Regards, 
Alex